|
willjo3 posted:I'm having a problem using the php mail() function. I've been googling and experimenting for two days trying to figure it out to no avail. what is the value of $mailheader in the original script?
|
# ? Jun 17, 2008 00:08 |
|
|
# ? May 16, 2024 08:44 |
|
duz posted:Anything you roll on your own will likely be easy to defeat, use reCAPTCHA instead. They provide sample code and libraries to help integrate it. This looks great, but because of the way this comment module is designed, I really just want a script that generates a captcha image - that would be the easiest solution. Is there a such thing as any library or script that generates pretty tough captchas?
|
# ? Jun 17, 2008 01:32 |
|
bt_escm posted:I have to question where you're getting the data from that you would need to sort it in php? It is a combination of physical file data and stuff from db, sortable by the user as needed. As some of it isn't db related I can't let the DB sort the data for me. But if you have any suggestions, feel free to offer them.
|
# ? Jun 17, 2008 03:16 |
|
dancavallaro posted:This looks great, but because of the way this comment module is designed, I really just want a script that generates a captcha image - that would be the easiest solution. Is there a such thing as any library or script that generates pretty tough captchas? http://www.google.com/search?q=php+captcha+generator
|
# ? Jun 17, 2008 04:43 |
|
Tap posted:I'm writing a script to validate URLs, and one part of the script validation is a check to see if the document exists (i.e. seeing if there's a response). Is there a faster function to use than get_headers? For me, get_headers is extremely slow and I'm going to be validating thousands of URLs. Try using fsockopen() or the cURL functions
|
# ? Jun 17, 2008 16:13 |
|
willjo3 posted:I'm having a problem using the php mail() function. I've been googling and experimenting for two days trying to figure it out to no avail. If it's a linux box, make sure sendmail is set up correctly. Here's some more information about setting up PHP mail correctly: http://email.about.com/cs/phpemailtips/qt/et031202.htm
|
# ? Jun 17, 2008 20:31 |
|
I have a file upload script based on this - http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2293&lngWId=8 but I need it to remove spaces in the file names before it uploads it to the server. How would this be done?
|
# ? Jun 17, 2008 20:33 |
|
Use some regex on it? I'm sure a regex genius will post how to do this in a few mins.
|
# ? Jun 17, 2008 22:00 |
|
drcru posted:Use some regex on it? I'm sure a regex genius will post how to do this in a few mins. str_replace actually. He got a hold of me via IM and got it worked out.
|
# ? Jun 17, 2008 22:13 |
|
Treytor posted:I have a file upload script based on this - http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2293&lngWId=8 To just remove spaces use this php:<? $string = str_replace(' ','',$string); ?> However if you are looking to make the filename safe for your file system then you should use a regular expression to replace any non-aplhanumeric characters like this php:<? $string = preg_replace('/[^A-Za-z0-9\\.\\-_]/','',$string); ?> bt_escm fucked around with this message at 22:26 on Jun 17, 2008 |
# ? Jun 17, 2008 22:16 |
|
iamstinky posted:It is a combination of physical file data and stuff from db, sortable by the user as needed. As some of it isn't db related I can't let the DB sort the data for me. But if you have any suggestions, feel free to offer them. Ok, the solution posted earlier will work. It's just unusual to have to sort a large block of data in php like that.
|
# ? Jun 17, 2008 22:28 |
|
duz posted:str_replace actually. He got a hold of me via IM and got it worked out. Yes. Thanks again! Also thank you bt for your input as well!
|
# ? Jun 17, 2008 22:34 |
|
So I want to write a small/simple/safe search engine for our MySQL database. How would I start this off? The fields I want to search are varchar(64) and longtext. Any specific links or tutorials?
|
# ? Jun 18, 2008 00:07 |
|
drcru posted:So I want to write a small/simple/safe search engine for our MySQL database. How would I start this off? Assuming you're using MyISAM, and you don't have more than 500,000 or so rows to search through, Fulltext indexes are the way to go. You pretty much add the index and write a query like this: code:
|
# ? Jun 18, 2008 00:32 |
|
Bruno_me posted:Assuming you're using MyISAM, and you don't have more than 500,000 or so rows to search through, Fulltext indexes are the way to go. You pretty much add the index and write a query like this: That was pretty easy to setup and it was fun. Thanks.
|
# ? Jun 18, 2008 03:12 |
|
I believe there is a quicker/easier/faster way to do this, but I can't recall it to save my life.php:<?php $row_id = 0; while ($row_id <= $foo['total_rows']) { $segment = 'media/album/' . $foo[$row_id]['id']; echo anchor($segment, $foo[$row_id]['name']); $row_id++; } ?>
|
# ? Jun 18, 2008 17:16 |
|
Hey guys, I have a question regarding a google spreadsheet query using php. The query expression on Google Spreadsheet in PHP is like this: quote:$name = 'John'; What I want to do is to search every record including 'John' NOT exactly 'John'. I know how I would do this using a simple SQL query but I don't know how I would do this using php and google spreadsheets because I am not very familiar with either. Any help would be GREATLY appreciated.
|
# ? Jun 18, 2008 17:31 |
|
slipfish posted:I believe there is a quicker/easier/faster way to do this, but I can't recall it to save my life. You could use a for loop or possibly a foreach loop instead.
|
# ? Jun 18, 2008 18:28 |
|
How do you guys deal with really long SQL queries in your PHP code? I'm dealing with some fairly complex cross-table queries for a new app and I'm oscillating betweencode:
|
# ? Jun 19, 2008 18:32 |
|
illamint posted:How do you guys deal with really long SQL queries in your PHP code? do this: php:<? $query = "SELECT ... FROM ... ORDER BY ... "; ?> Edit: Also, a pro-tip: When putting comma-separated things onto separate lines, put the commas at the start and line them up. That way you can easily see when a comma is missing, which is harder to do when commas go at the end. Plus, it's easier to add new lines to the end and not miss putting the comma in. Example: php:<? $sql = "CREATE TABLE foo ( bar integer , baz string , wiz float , waz integer , PRIMARY KEY (bar) ) "; ?> minato fucked around with this message at 18:40 on Jun 19, 2008 |
# ? Jun 19, 2008 18:37 |
|
illamint posted:I don't see anything really wrong with my first method, assuming that the interpreter will interpret the string literal as a whole and not instantiate 3 string objects, concatenate them, and return a whole new string object. Is this an OK way of doing it? Even if it internally does that, why does it matter? Go for readability. Split it into as many pieces as necessary. edit: drat, minato beat me and his answer is better.
|
# ? Jun 19, 2008 18:37 |
|
Could a PHP script be used to ping a server, and redirect to two different pages depending on whether the pinged server responds or not?
|
# ? Jun 19, 2008 18:37 |
|
Treytor posted:Could a PHP script be used to ping a server, and redirect to two different pages depending on whether the pinged server responds or not? Certainly.
|
# ? Jun 19, 2008 18:39 |
Treytor posted:Could a PHP script be used to ping a server, and redirect to two different pages depending on whether the pinged server responds or not? PEAR Ping Redirect with this
|
|
# ? Jun 19, 2008 18:46 |
|
slipfish posted:I believe there is a quicker/easier/faster way to do this, but I can't recall it to save my life. As suggested above, maybe: php:<?php foreach($foo as $bar) { $segment = 'media/album/'.$bar['id'] echo ancher($segment,$bar['name']); } ?> Un-l337-Pork fucked around with this message at 19:12 on Jun 19, 2008 |
# ? Jun 19, 2008 19:08 |
|
I've been having a problem where the following is throwing out a syntax error and i for the life of me can't find the problemphp:<? $check = mysql_query("SELECT 'id', 'fname', 'lname', 'active', 'type' FROM 'users' WHERE 'email' = $email AND 'pass' = $pass") or die(mysql_error()); ?>
|
# ? Jun 21, 2008 14:07 |
|
blunt posted:I've been having a problem where the following is throwing out a syntax error and i for the life of me can't find the problem Single quotes go around string literals, not around column names: php:<? $check = mysql_query("SELECT id, fname, lname, active, type FROM users WHERE email = '$email' AND pass = '$pass'") or die(mysql_error()); ?>
|
# ? Jun 21, 2008 14:36 |
|
Standish posted:Single quotes go around string literals, not around column names: I could swear to god i'd tried that but low and behold it works perfectly. Much appreciated
|
# ? Jun 21, 2008 14:57 |
|
fletcher posted:PEAR Ping Thanks for this, but I am having problems getting PEAR to work with my web host, I think they may be blocking some functions required by PEAR to operate... Is there any other option (preferably without requiring a framework?) I found this script here: http://www.greenbird.info/xantus-webdevelopment/ping Which seems to work on their site, but when I upload it and test on my own server, I'm getting a reported ping response from all servers, including the fake one... Treytor fucked around with this message at 08:58 on Jun 22, 2008 |
# ? Jun 22, 2008 08:39 |
|
I need to read 8-bit alpha channels from PNGs. GD only supports 7-bit alpha channels, and the documentation says something to the effect of "why would you ever want to properly read PNGs 7-bits are plenty for an alpha channel " so I don't think they're going to add it any time soon. Now, I have two choices that I'm aware of. I can use ImageMagick (I'm assuming), but it's poorly(read: not) documented. So I don't even know if this is an option. I can also parse the file data myself. This is the route I went, but again, I'm having trouble finding adequate documentation. The official documentation is excellent in explaining how to read header data, separating chunks, etc. As soon as it gets to reading IDAT information, however, it mentions decompressing it, and that's pretty much it. My understanding from the documentation is that the data is formatted like this: code:
So, I guess I'm asking for a hint on any of the above. Maybe I've missed a hidden 8-bit alpha in GD, or an explanation of the png data format, or even a recommendation to try and puzzle out ImageMagick. Something like that.
|
# ? Jun 22, 2008 10:56 |
|
ante posted:I need to read 8-bit alpha channels from PNGs. http://www.php.net/imagick Here's a crappy example: php:<? $image = new Imagick('image.png'); $width = $image->getImageWidth(); $height = $image->getImageHeight(); $iterator = $image->getPixelIterator(); foreach ($iterator as $y => $pixels) { foreach ($pixels as $x => $pixel) { $color = $pixel->getColor(true); // color is an array like array('r' => ..., 'g' => ..., 'b' => ..., 'a' => ...) // passing true to getColor() returns them in floats, // so to get the 'real' value you just multiply the values by 255. } $iterator->syncIterator(); }?> It's crude but it works. To answer your question about the PNG format: All IDAT blocks are joined together as one block of data, this data is compressed with zlib, after you decompress it, you'll get an amount of data depending on the image settings in the IHDR. Your understanding of this data format is correct, each scan line has a filter type associated with it, this filter type determins how the data for that scanline is stored. http://www.cs.toronto.edu/~cosmin/pngtech/optipng.html Skip down to "2.2 The PNG delta filters". gibbed fucked around with this message at 11:37 on Jun 22, 2008 |
# ? Jun 22, 2008 11:29 |
|
gibbed posted:To answer your question about the PNG format: Anyway. Looks like I won't need it if I use Imagick. Thanks. That's exactly what I was looking for.
|
# ? Jun 22, 2008 12:00 |
|
Really dumb question: I'm outputting the results of a mysql query into a page and loading it into a javascript array. Right now it is essentially like this: code:
The code works in IE/Firefox/Safari, but of course it produces javascript errors. What is an easy way to say "on the last record truncate the comma" ?
|
# ? Jun 22, 2008 23:40 |
|
passionate dongs posted:Really dumb question: You could always do something like this (as long as it's an array): code:
|
# ? Jun 22, 2008 23:51 |
|
MrEnigma posted:You could always do something like this (as long as it's an array): this helped a lot and now I feel stupid, thanks!
|
# ? Jun 23, 2008 00:30 |
|
Does anyone have or know how to write a script that can grab popular IM online status? e.g. AIM, MSN, Yahoo, etc. I figured out how to grab user's online status for AIM, but couldn't find anything for MSN, Yahoo, or others... any tips would be greatly appreciated!
|
# ? Jun 23, 2008 00:31 |
Treytor posted:Thanks for this, but I am having problems getting PEAR to work with my web host, I think they may be blocking some functions required by PEAR to operate... Email your host and ask them to fix this. If they don't, find a new web host.
|
|
# ? Jun 23, 2008 19:08 |
|
fletcher posted:Email your host and ask them to fix this. If they don't, find a new web host. You usually can just manually include the PEAR files in your script if you can't run the actual pear software, basically the same thing. A lot of hosts won't use the extension, but it doesn't stop you from using the code.
|
# ? Jun 23, 2008 19:14 |
|
blunt posted:I could swear to god i'd tried that but low and behold it works perfectly. Much appreciated Use a DB abstraction layer fer god's sake. You're just making life harder for yourself if you don't.
|
# ? Jun 24, 2008 03:04 |
|
|
# ? May 16, 2024 08:44 |
|
I was using ip2c (free IP to country database) for a while until it broke. Even the new version keeps breaking, I pasted the errors on pastebin. Has anybody experienced this too, or any idea why? The PHP files DO point to the database files correctly, which confused me.
|
# ? Jun 24, 2008 03:39 |