[PHP] Re: excuting several sql statements in one time
Hey, Whilst you can't perform statements like this, there are alternatives. If you only have one field in your table, you can use: INSERT INTO com VALUES ('pentium'), ('amd'); // Continue the comma separated values list Or, if you need to specify which fields the data is to go in: INSERT INTO com (column1, column2) VALUES ('something', 'something else'), ('something again', 'something else again'); James VM ÁÖ¿N [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello I want to know how to implement these several sql statements in one time. For example, I have 2 sql statements like : INSERT INTO com VALUES ('pentium'); INSERT INTO com VALUES ('amd'); Then, I want to excute these 2 sql statements in one time with PHP. I tried to implement like this : $query = INSERT INTO com VALUES ('pentium'); INSERT INTO com VALUES ('amd'); ; mysql_query($query, $dbconnect); But as you know, it didn't work. Does any one know how to run this job? _ MSN Explorer¡Æ¢® AOA¢¬¢¬e Hotmail ¡íc¢¯eAI EI¨úA ¨¡i¢¬RC¨ª Ay¢¥I¢¥U. Ao¡¾Y http://explorer.msn.co.kr/ ¢¯¢®¨ù¡© ©ö¡ì¡¤a¡¤I ¢¥U¢¯i¡¤I¥ìaCI¨ù¨ù¢¯a. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: problem with form values
Sorry, I didn't mean it quite like that. After the user presses submit $string = htmlentities($string); // now, do whatever with the string J - Original Message - From: Niklas Lampén To: James Holloway ; Php-General Sent: Wednesday, September 12, 2001 9:52 AM Subject: RE: problem with form values How to do anything to the strings in php BEFORE the form is sent? Niklas -Original Message- From: James Holloway [mailto:[EMAIL PROTECTED]] Sent: 12. syyskuuta 2001 11:28 To: Niklas lampén Subject: Re: problem with form values Hi Niklas, use htmlentities() or htmlspecialchars() on the string before the form is sent. See the manual for more info. James - Original Message - From: Niklas lampén Newsgroups: php.general To: Php-General Sent: Wednesday, September 12, 2001 8:32 AM Subject: problem with form values If a user enters a quota ( ) to a form field and sends it, the page trying to process values gets only a backslash ( \ ). No matter if I use GET or POST. How to get the right kind of a value? Niklas
[PHP] Re: just 10 characters from a string
Hi Marcos, use substr(); http://www.php.net/manual/en/function.substr.php $string = substr($string, 0, 10); James Marcos Lloret [EMAIL PROTECTED] wrote in message 019701c131f1$f57bdfa0$371c94c1@mlloret">news:019701c131f1$f57bdfa0$371c94c1@mlloret... hi to all, i have a long string (about 255 characters) and i would like to show only 10. how can i do it? thanks in advance, marcos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: parse error AFTER end of included file??
Jaxon, do you have a line of white space after your closing tag? Anyway, this looks fishy to me: if (!isset($page_id)) { $sql=select page_id from table where fieldname = $value; $link_id = mysql_connect($host, $usr, $pass) or die (mysql_error()); mysql_select_db($database, $link_id); //select database catalog $result = mysql_query ($sql, $link_id) or die (mysql_error()); //return result set to php if (!$result) echo wait - no result set!; $page_id = mysql_result($result, 0, fieldname); // Where is the closing } for if (!isset($page_id)){ ? // added it below } I think you'd benefit from using braces more often too, so your style is consistent. so changing if (!$result) echo wait - no result set!; to if (!$result) { echo wait - no result set!; } might mean that you're able to spot things like this more easily. Just my opinion ;) James Jaxon [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, Can anyone tell me why I have a parse error here? I'm including this file, which is 16 lines, but the error being thrown by the including page reports a parse error in this file on line 17 ???: ?php if (!isset($page_type)) { $page_type = foo; } if (!isset($page_id)) { $sql=select page_id from table where fieldname = $value; $link_id = mysql_connect($host, $usr, $pass) or die (mysql_error()); mysql_select_db($database, $link_id); //select database catalog $result = mysql_query ($sql, $link_id) or die (mysql_error()); //return result set to php if (!$result) echo wait - no result set!; $page_id = mysql_result($result, 0, fieldname); ? cheers, jaxon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: mySQL Query - comparing multiple values with one field
Hi Niklas, You can use || or OR. Secondly, huge list of values you say? Can this list be exploded by a common denominator, like a space or comma? If so, consider this: $list = // Huge list of words (array), separated by a comma. $words = explode(,, $list); $query = SELECT * FROM table WHERE ; for($i = 0; $i = sizeof($words); $i++) { $query .= field LIKE '% . $words[$i] . %' OR ; } $query = substr($query, 0, -4); // need to take out: [[:space:]]OR[[:space:]] from the end $do_query = @mysql_query($query); Cheers, James What I need to do is to compare if one field matches a value from a huge list of values. Do I need to query like SELECT * FROM table WHERE field LIKE '%value1%' || field LIKE '%value2%' or can I do it something like this SELECT * FROM table WHERE field LIKE ('%value1%' || '%value2%')? Niklas Lampén -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: File uploads in PHP
Hi there, I haven't tested any of this, and there are probably some things that need adding, but it'll give you an idea at least. Form element: input type=file name=thefile // What files do we want? $types_we_want = array(image/gif, image/jpeg, image/pjpeg); // allows jpegs and gifs // What is the max size we want (in bytes)? $size_we_want = (50 * 1024); // 50Kb // function to test whether or not the file is an image, and whether it is in the correct // size restriction function CheckImage($thefile, $thefile_name, $thefile_type, $thefile_size, $types_we_want, $size_we_want) { if (!in_array($thefile_type, $types_we_want)) { // the file is of invalid type return false; } else if ($thefile_size $size_we_want) { // too big return false; } return true; } // function to explain what's wrong with the file function AnImageError($thefile, $thefile_name, $thefile_type, $thefile_size, $types_we_want, $size_we_want) { if (!in_array($thefile_type, $types_we_want)) { // the file is of invalid type echo $thefile_name . is not a jpeg or gif!; } else if ($thefile_size $size_we_want) { // too big echo $thefile_name . is bigger than the allowed file size of . ($size_we_want / 1024) . Kb; } } // function to change the name of the image (if you don't do this, and one person // uploads a file named name.jpg and then another person uploads a file with // the same name, the second will overwrite the original function NewImageName($thefile_name, $thefile_type) { $timestamp = time(); // use a timestamp $prefix = substr($thefile_name, 0, 2); // get two characters from the beginning of the filename // for a bit of randomness (use another function like mtsrand() (see manual)) // for something better if ($thefile_type == image/jpeg || $thefile_type == image/pjpeg) { // file is a jpeg $ext = .jpg; } else { // file is a gif $ext = .gif; } $newfilename = $prefix . $timestamp . $ext; return $newfilename; } // function to upload the file. function DoUploadFile($thefile, $thefile_name, $thefile_type, $thefile_size) { global $connection; // this contains details of your mysql connection $size = @GetImageSize($thefile); list($ignoreme,$width,$ignoremeagain,$height) = explode(\,$size[3]); // gets the width and height of the file // rename the image with the function we defined above $newfilename = NewImageName($thefile_name, $thefile_type); // specify a directory to copy the temp file to in the following line // eg /home/mysite/web/images if (!@copy($thefile, /path/to/store/files . $newfilename)) { echo Sorry, something's gone wrong here.; } else { // insert the data into your table. the columns are the unique id of the file, // the date the file is uploaded in datetime format, // the name of the file (varchar, 50), its size in bytes( int), its width(int) and height(int). $insert_data = INSERT INTO mysql_table (picid, picorigin, picname, picsize, picwidth, picheight) VALUES ('', NOW(), '$newfilename', '$thefile_size', '$width', '$height'); $do_upload = @mysql_query($insert_data, $connection); if (!$do_upload) { // query failed echo There was an error with the database.; } else { echo Thanks. . $thefile_name . has been uploaded.; } } } // Put it all together in your form handling if ($thefile_name != ) { if (!CheckImage($thefile, $thefile_name, $thefile_type, $thefile_size, $types_we_want, $size_we_want)) { AnImageError($thefile, $thefile_name, $thefile_type, $thefile_size, $types_we_want, $size_we_want); } else { DoUploadFile($thefile, $thefile_name, $thefile_type, $thefile_size); } } Hope that helps, James. Dr. Evil [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... My PHP script needs to receive some files. I've seen sites which accept them; they have a Browse button which lets the user select a file to send. That's what I want to do. I have a few questions about this. First of all, this is with php4.06. Secondly, the files are all going to be images, and not very large: no more than 50k. What's the best way to do this? I notice that PHP can store these files on disk, but I'm going to be storing them in a DB. I would rather receive them directly into a PHP variable. Is this possible? Or should I take them in a file, and then read them back in to a variable? Also, if they need to go into a file, which directory is safest for this? /tmp contains some important files. And finally, how do I limit the maximum file size that PHP will accept? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL
Re: [PHP] Upper or Lower Case
Hi Taz, What happens if they type NeO, or NEO, or nEo, or neO (etc)? ;) Also, if you're using this in a large application (or intend to in the future), are you going to type out all of the names as you have done with the neo example? Bjorn's method is much better, and you're better off getting into good practice early. James Tarrant Costelloe [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Ok thanks, I found jons way the easiest: if ($name == neo || $name == Neo) -Original Message- From: Bjorn Van Simaeys [mailto:[EMAIL PROTECTED]] Sent: 07 August 2001 16:24 To: [EMAIL PROTECTED] Subject: Re: [PHP] Upper or Lower Case Hi, I have run accross this problem too, and I solve it this way: if(strtolower($name1) == strtolower($name2)) I compare both variables in lower case, this way capitals don't matter at all. Greetz, Bjorn Van Simaeys www.bvsenterprises.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: array + checkbox
Hi there Tijmen, Firstly, change the input name from this: voorraad to this: voorraad[] then do something like: ? echo Checked values are as follows:brbr; for ($i = 0; $i sizeof($voorraad); $i++) { if (!empty($voorraad[$i])) { echo $voorraad[$i]; } } ? James Tijmen Hennink [EMAIL PROTECTED] wrote in message 001601c11e52$d328e9f0$80c2a8c0@PATRIJS2000">news:001601c11e52$d328e9f0$80c2a8c0@PATRIJS2000... Hi All, I've the following weird problem. I have a form which contains an array with values of some checkboxes. This is the HTML-part: INPUT TYPE=checkbox name=voorraad checked if checked or INPUT TYPE=checkbox name=voorraad Now I want to check which of the checkboxes are really checked. So I've got the following PHP code: if(count($voorraad[1])0) { echo VOORRAAD NEE; } else { echo VOORRAAD JA; } I've tried it with isset($voorraad[1]), count, is_null($voorraad[1]) but all the functions doesn't work. Does anyone see what I'm doing wrong?? Met vriendelijke groet/with kind regards, Tijmen Hennink [EMAIL PROTECTED] Medi@connect Dit e-mail bericht is uitsluitend bestemd voor de geadresseerde(n). Gebruik van deze informatie door andere dan de geadresseerde is verboden. Het is evenmin toegestaan om deze informatie openbaar te maken, te vermenigvuldigen, te verspreiden of te verstrekken aan derden. Aan dit bericht kunnen geen rechten worden ontleend. Indien u dit mailtje heeft ontvangen terwijl het niet aan u gericht was, reply richting mij en verwijder vervolgens de email en uitgeprinte versies van dit mailtje. This e-mail is intended for the use of the addressee(s) only and may contain privileged, confidential, or proprietary information that is exempt from disclosure under law. If you have received this message in error, please inform me promptly by reply e-mail, then delete the e-mail and any printed copy. Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Generating mysql statement from php return an error :-(
If you want to separate insert statements, you can do it like this: $big_insert_query = INSERT INTO table (id, col1, col2) VALUES ('', '$col1_stuff[$i]', '$col2_stuff[$i]'), ('', '$col1_stuff[$i]', '$col2_stuff[$i]'), ('', '$col1_stuff[$i]', '$col2_stuff[$i]'), ('', '$col1_stuff[$i]', '$col2_stuff[$i]'); Ie, you specify the columns, and the values are a comma separated, bracket enclosed list. I dunno whether this frees up any resources, or has any major advantages, though it's probably better practice ;) I think this is only available in 3.22 or higher, though I could be wrong James Ben Bleything [EMAIL PROTECTED] wrote in message 000801c11895$0d43b7a0$0201a8c0@allegro">news:000801c11895$0d43b7a0$0201a8c0@allegro... I _believe_ (not totally sure) that mysql_query() can only handle one statement at a time, and if you need to execute multiple, you will need to use more than one mysql_query() statements. It's a bummer = I have all sorts of problems with it. What's up with your return e-mail address? It's a pain in the ass for all mails to you bouncing... Ben -Original Message- From: Jacques [mailto:[EMAIL PROTECTED]] Sent: Sunday, July 29, 2001 5:47 PM To: [EMAIL PROTECTED] Subject: [PHP] Generating mysql statement from php return an error :-( Hi, I'm using a table in my session to store my variable to generate later my sql statements. Until now... nothing very weird ! But when I want to generate my sql statement. I've got an error after the first line where I put a comma ; to make a difference within my statements. this is a portion of my code : $query.=Insert into product (id_quote,item,description,quantity,unit_price,ext_price,lead) values ('$QUOTE_NUMBER' , '.$TABLE_QUOTE_PRODUCT[$y][item].' , '.$TABLE_QUOTE_PRODUCT[$y][description].', '.$TABLE_QUOTE_PRODUCT[$y][qty].' , '.$TABLE_QUOTE_PRODUCT[$y][unitprice].' , '.$TABLE_QUOTE_PRODUCT[$y][extprice].' , '.$TABLE_QUOTE_PRODUCT[$y][leadtime].');\n; } $result=mysql_query($query); If I have only one line in my sql and I remove the ; it works. but If I add the ; to separate two sql lines error ! Any idea how I can resolve this problem ? Regards, Jacques -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Help with regular expresions! [ASAP]
Hi Peter, You could try this: ? $string = Blah iitalic/iinput type=\name\ Blah bbold/b; $new_string = preg_replace(/input(.*?)/i, input\\1 class=3D, $string); echo $stringbrbr$new_string; ? preg_replace = regular expression replacement input = first part of tag (.*?) = whatever, but not: .* is greedy... Match any character . as many times * as necessary, made less greedy because the ? looks for whatever's to the right of it If you did: preg_replace(/input(.*)/i, input\\1 class=3D, $string); it might replace input type=text name=blahinput type=file with input type=text name=blahinput type=file class=3D Instead of input type=text name=blah class=3Dinput type=file class=3D Which is what you want. The \\1 is what you have captured from the first (and in this case, only) set of parentheses () The i after the delimiter means case insensitive. Note, I didn't have time to check that this works, but you get the principle :) James Psychosphere2k [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi! I have a fairly large PHP based website. Unfortuantely, I didn't make extensive use of stylesheets. I'm hoping for some help with regular expressions matching ( and = replacing ) some tags. I use output buffering, so it would be a simple case of adding some = lines to my output hanlder. eg: replacing input with input class =3D something and body with body class =3D something_else Some code, with comments would be really great. Thanks in advance. Peter Gibson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] date HELP !!!!!
Better still, use the date(t); to find out how many days are in the given month. This part of the date function is a blessing, given the varying days in months, and the fact that we've a leap year every four years. James Daniel Rezny [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello Yamin, Monday, July 23, 2001, 9:27:46 AM, you wrote: YP hi, YP how do i check that the current date is the end of month YP Thanks in Advance If you want to check how long is current month and use this value later you can use this: $month=(m); //can be like this depend on if you scrolling between moths. If yes variable $month must be recieved from link. $d=27; while ($d = 32) { $mon = date(m,mktime(0,0,0,$month,$d,$rok)); if ($month != $mon) { $daylast = $d-1; $d=33; } else { $d++; } } I hope it helps. -- Best regards, Danielmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: reg exp help
Hi Justin, for the username, you can use: if (!preg_match(/^[a-z0-9]*$/, $username)) { // error } else { // ok } The ^ means start of the string, the characters between the [ and ] are ones that we want, the * means however many times, and the $ means the end of the line / string. So if there isn't a match against lower case letters and numbers throughout the string (from start to finish), there's an error. I'd advise you to go more complex with the email address. James. Justin French [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... hi all, two quick reg exp problems: one: $username must only contain a-z lowercase, 0-9, no spaces, no other characters. what would the regexp be? if(ereg(, $username)) { $valid = yes } else { $valid = no) two: i want to do a really small email validation, just to make sure the email probably right, as in: [EMAIL PROTECTED] what's the best reg exp to use. i'm aware there are email validating script out there, but I want to learn for myself many thanks in advance justin french -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Replace ANYTHING between TAG /TAG
Hi Dan, maybe something like: $newvariablethatwewantbetweenthetags = Long variable!; $string = preg_replace(/(TAG)(.*?)(\/TAG)/i, \\1$newvariablethatwewantbetweenthetags\\2, $string)); There should be a after and before the second part of that statement, but my email proggy strips them. James Dan Krumlauf [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I've been trying this one for a bit and Im in a twist. I need to replace ANYTHING or even nothing between two tags with the contents of a variable and just havent been able to get the expression right for all cases. As an example concept follows: TAG/TAG Nothing between the tags variable is $varname=some junk so after the function TAGsome junk/TAG run it again after making variable $varname=some completly different junk so now the tags would be TAGsome completly different junk/TAG and so on and so on. One other breaker Ive had, it needs to always replace no matter whats between the tags, whats not between the tags or even if its 1000s of characters. My code kept breaking when it was alot of characters. Any funtions or even just the right regex would be appreciated Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: limit items per page
Hi Steph, as the name suggests, use LIMIT ;) Ie, SELECT * FROM TABLE LIMIT 0,25 The 0 (or other number) is optional, and tells the table which row to start limiting from, the secon number is the number of rows to limit to.. So: SELECT * FROM TABLE LIMIT 25,25 Would bring out 25 rows, starting from row 25 (rows 25 to 50). See the documentation at the mysql site for more info. Cheers, James. Steph [EMAIL PROTECTED] wrote in message 001701c11354$db6b2fa0$ab8d7a3f@vaio">news:001701c11354$db6b2fa0$ab8d7a3f@vaio... Ive got an image gallery, and rather than having one really long page of thumbnails, I'd like to have around 25 thumbnails (5 rows of 5 thumbs) per page. Can you guys point me in the right direction?? Steph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: limit items per page
Perhaps I shouldn't have made the assumption that steph was using mysql :) Henrik Hansen [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... [EMAIL PROTECTED] (James Holloway) wrote: Hi Steph, as the name suggests, use LIMIT ;) AFAIK it's mysql specific (at least it does not work with mssql) -- Henrik Hansen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Using Frames
Hi Mark, yes it's possible, but with javascript rather than php Do a search on a javascript related site for window.frames James. Mark Lo [EMAIL PROTECTED] wrote in message 000701c11021$c66111a0$caccfea9@Mark">news:000701c11021$c66111a0$caccfea9@Mark... Hi, I would like to know how to make all three frames to move at the same time. Actually is it possible ?? Thanks Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] SQL in array() ?
Hey guys, I saw a post in here the other day that's prompted me to ask this question... Because I can't seem to get the solution mentioned to work. Maybe I'm missing something obvious... Anyway, here goes. I have a list of categories contained in one table, and a list of entries in another. So categories: id name 1 category1 2 category2 3 category3 At the moment, the entries table has a field which contains a field mentioning the category by id, so: entries id cat_id name 1 1 name1 2 1 name2 3 1 name3 The problem is this: I'd like to give some entries more than one category. I attempted to put the category id's into an array. So a row in the revised entries table now looks like this: entries id cat_id name 1 2 name1 2 1,3 name2 3 1 name3 And I'm trying to list from that table with code similar to this: ? $cat[0] = 1; $cat[1] = 3; $getcats = implode(,, $cat); $query = @mysql_query(SELECT * FROM entries WHERE cat_id IN($getcats)) or die (mysql_error()); // Get the results ? I get no errors when executing that code, but I don't get any results back, either.. even though I know there are entries in the table with the category id listed as 1,3 Any ideas? I'm having one of those days :) Cheers, James. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: how to strip just the img tag from html file?
Hi Shawna Look up preg_replace(); Assuming $file is the contents of your file - $file = preg_replace(/img.*?/i, , $file); James. [EMAIL PROTECTED] wrote in message BB6D932A42D6D211B4AC0090274EBB1D2EEF63@GLOBAL1">news:BB6D932A42D6D211B4AC0090274EBB1D2EEF63@GLOBAL1... I've created a printer-friendly version of a page (PHP/MySQL) and want to have just the img tags automatically removed. I thought about using strip_tags() but I'm not able to predict what html tags to include as the exceptions so that they would not be removed too. How can I do this? Thank you! - Shawna -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Cookie Expiry Dates?
Hi Jeff, Yes, use time() Example 86400 seconds in a day. 3600 in an hour. Use some basic maths: $cookie_expire = time() * 86400 * 365; // Sets cookie for a year (365 days). James. Jeff Lewis [EMAIL PROTECTED] wrote in message 006101c10a08$874f93c0$76a1a8c0@LEWISJCIT">news:006101c10a08$874f93c0$76a1a8c0@LEWISJCIT... I'd like to set a cookie that never expires or at least one that lasts a month, how can I set it? Does it have to be with time? I am using SetCookie. Jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Searching a MYSQL DB
Hey, Simple solution: ? $search = hammer; $connection = // Connection to the database details. $query = @mysql_query(SELECT * FROM table WHERE Name LIKE '%$search%' OR Description LIKE '%$search%' ORDER BY Name ASC, $connection) or die (mysql_error()); while($row = mysql_fetch_array($query)) { $name = $row['Name']; $description = $row['Description']; echo b . stripslashes(htmlentities($name)) . /b\nBR\n . stripslashes(htmlentities($description)) . BRBR\n; } ? James. YoBro [EMAIL PROTECTED] wrote in message 9eg0jl$5ac$[EMAIL PROTECTED]">news:9eg0jl$5ac$[EMAIL PROTECTED]... Hi, Any ideas, or any code that will allow a search of specific keywords in a mysql database. Feilds in a Table called: Name Description What I am after is if somebody types the word 'hammer', then I want it to return the results in a list if the word hammer is picked up under the name of description feilds. Is this easier enough to do? YoBro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] How to select rows from Mysql with case senstive ??
Hey try this, though there are probably better ways, SELECT * FROM foo WHERE name REGEXP '^[PHP]'; James Bass¨Ð¦õªv [EMAIL PROTECTED] wrote in message 9egfot$cfu$[EMAIL PROTECTED]">news:9egfot$cfu$[EMAIL PROTECTED]... Hi , By defualt , select rows from Mysql is case insenstive . For exmaple , select * from foo where name = 'PHP' select * from foo where name = 'php' is the same how can i do a queny which select * from foo where name = 'PHP' is success but select * from foo where name = 'php' fail ?? given that name = 'PHP' in the database thx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] How to select rows from Mysql with case senstive ??
*Shrug* Don't have time to test at the moment... That was taken from Chapter 9.3.4.7 of the MySQL manual http://www.mysql.com/doc/P/a/Pattern_matching.html Prior to MySQL Version 3.23.4, REGEXP is case sensitive, and the previous query will return no rows. To match either lowercase or uppercase `b', use this query instead: mysql SELECT * FROM pet WHERE name REGEXP ^[bB]; Was worth a try :) James. Martín Marqués [EMAIL PROTECTED] wrote in message 01052312020905.03109@bugs">news:01052312020905.03109@bugs... On Mié 23 May 2001 17:56, you wrote: Hey try this, though there are probably better ways, SELECT * FROM foo WHERE name REGEXP '^[PHP]'; This is not SQL compatible. This would be a correct SQL statement: SELECT * FROM foo WHERE name LIKE [PHP]% Saludos... :-) -- Cualquiera administra un NT. Ese es el problema, que cualquiera administre. - Martin Marques |[EMAIL PROTECTED] Programador, Administrador | Centro de Telematica Universidad Nacional del Litoral - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] e*reminder and cron
Hi Henry, I'm not too familiar with Cron, but check the man pages for cron and crontab (type 'man cron' or 'man crontab', or type 'man man' if you've not used man pages before). James. Henry [EMAIL PROTECTED] wrote in message 018b01c0e19d$544818a0$046265cb@henry">news:018b01c0e19d$544818a0$046265cb@henry... i'd like to run something like http://sourceforge.net/projects/e-reminders/ on my site. it uses cron to trigger the mail to be sent. i'm not familiar with unix and cron. apparently i need to use shell access on my site to get this working. anybody got any tips to get cron working in the simplest way. cheers Henry http://www.bigjolt.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] checking to see if part of a variable exists?
Hi Sandeep, ? if (preg_match(/@monkeys.com/i, $variable)) { echo Got some monkeys.; } else { echo No monkeys here.; } ? preg_match(); ereg(); eregi(); Will all help you. James. Sandeep Hundal [EMAIL PROTECTED] wrote in message A0A5617A0A05D5118EBD00508B8B953B5EA932@PROF-X">news:A0A5617A0A05D5118EBD00508B8B953B5EA932@PROF-X... hi all! i need to see if a $variable has a piece of text included in it. how do i do that? i need to do something like: if ($variable =matches= @monkeys.com) { then do this} tia! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Quotes in GET variables
Hi Mark, It's nice in that it adds to how secure PHP code is, but it can be a hassle. Out of curiousity, what are the security implications? Presumably a failure to validate input properly leading to unintended actions, but I can't think of any examples to help me decide whether to turn this off. Most default to set magic_quotes_gpc on - otherwise, to safeguard against (amongst many other things) mysql or other database errors, all fields that aren't integers would have to have addslashes() applied to them. Try entering a string like this: $string = a href=\http://www.php.net\;PHP/a; $string = stripslashes($string); $insert = @mysql_query(INSERT INTO table (string) VALUES ('$string')) or die (mysql_error()); And see how fast you run into errors ;) James. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Check multiple cookies
Hi Sam, The following is exactly what I typed in (just copy and pasted) but I'm still getting the error: Cannot add header information - headers already sent by (output started at web.php:2) in web.php on line 19 Make sure that all output for Cookies and header information is sent before any HTML, and that there is no whitespace before the initial ? tag - that's probably the source of the problem. Have a search for Output buffering on the PHP main site. James. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problem with PHP_SELF
Hi Richard. Two methods, POST and GET: Post for forms and best works with hidden elements. Get can be put across URL's: echo a href=\$PHP_SELF?page=$next_page$metode=$search\Next/a; Or FORM ACTION=? echo $PHP_SELF; ? METHOD=POST INPUT TYPE=hidden NAME=? echo $metode; ? VALUE=? echo $search; ? INPUT TYPE=Submit NAME=Submit VALUE=Next /FORM Of course form buttons look dreadful, so if you use that method, create a graphic to use, or do a javscript work around for text links. Hope that helps :) James. Richard Kurth [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am having a problem with this script. It works perfect if I just do a Query like (SELECT * FROM customers) but if I call it from another script with a form to set the search criteria for this Query (SELECT * FROM customers WHERE $metode LIKE '%$search%') It will show the first page but it gives me a error for any other page the problem is it does not pass the $metode $search on to the next page with PHP_SELF (look at bottom of script) How can I make it retain the variables to the next page? // Number of entries per page $per_page = 3; $sql_text = (SELECT * FROM customers WHERE $metode LIKE '%$search%'); // Set page #, if no page is specified, assume page 1 if (!$page) { $page = 1; } $prev_page = $page - 1; $next_page = $page + 1; $query = mysql_query($sql_text); // Set up specified page $page_start = ($per_page * $page) - $per_page; $num_rows = mysql_num_rows($query); if ($num_rows = $per_page) { $num_pages = 1; } else if (($num_rows % $per_page) == 0) { $num_pages = ($num_rows / $per_page); } else { $num_pages = ($num_rows / $per_page) + 1; } $num_pages = (int) $num_pages; if (($page $num_pages) || ($page 0)) { } // // Now the pages are set right, we can // perform the actual displaying... $sql_text = $sql_text . LIMIT $page_start, $per_page; $query = mysql_query($sql_text); ? table border=1 align=center tr align=center valign=top bgcolor=#86B3E3 tdh3Plan/h3/td tdh3Domain/h3/td tdh3First Name/h3/td tdh3Last Name/h3/td tdh3Company/h3/td tdh3Email/h3/td tdh3User Name/h3/td tdh3Password/h3/td /tr ? //$query = mysql_query(SELECT * FROM customersWHERE $metode LIKE '%$search%' LIMIT 0, 30 ); while ($row = mysql_fetch_array($query)) {$plan=$row[plan]; $domaname=$row[domaname]; $fname=$row[fname]; $lname=$row[lname]; $company=$row[company]; $email=$row[email]; $cusername=$row[cusername]; $cpassword=$row[cpassword]; echo tr align='center'; print (tdstrong$plan/strong/tdtdstrong$domaname/strong/tdtdstr ong$fname/strong/td tdstrong$lname/strong/tdtdstrong$company/strong/tdtdstron g$email/strong/tdtdstrong$cusername/strong/tdtdstrong$cpass word/strong/tdbr); echo /tr; } echo /table; // Previous if ($prev_page) { echo a href=\$PHP_SELF?page=$prev_page\Prev/a; } // Page # direct links for ($i = 1; $i = $num_pages; $i++) { if ($i != $page) { echo a href=\$PHP_SELF?page=$i\$i/a; } else { echo $i ; } } // Next if ($page != $num_pages) { echo a href=\$PHP_SELF?page=$next_page\Next/a; } Best regards, Richard mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problem with PHP_SELF
Gah! Forgot an element for that form: Page element. INPUT TYPE=hidden NAME=page VALUE=? echo $next_page; ? :) Hi Richard. Two methods, POST and GET: Post for forms and best works with hidden elements. Get can be put across URL's: echo a href=\$PHP_SELF?page=$next_page$metode=$search\Next/a; Or FORM ACTION=? echo $PHP_SELF; ? METHOD=POST INPUT TYPE=hidden NAME=? echo $metode; ? VALUE=? echo $search; ? INPUT TYPE=Submit NAME=Submit VALUE=Next /FORM Of course form buttons look dreadful, so if you use that method, create a graphic to use, or do a javscript work around for text links. Hope that helps :) James. Richard Kurth [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am having a problem with this script. It works perfect if I just do a Query like (SELECT * FROM customers) but if I call it from another script with a form to set the search criteria for this Query (SELECT * FROM customers WHERE $metode LIKE '%$search%') It will show the first page but it gives me a error for any other page the problem is it does not pass the $metode $search on to the next page with PHP_SELF (look at bottom of script) How can I make it retain the variables to the next page? // Number of entries per page $per_page = 3; $sql_text = (SELECT * FROM customers WHERE $metode LIKE '%$search%'); // Set page #, if no page is specified, assume page 1 if (!$page) { $page = 1; } $prev_page = $page - 1; $next_page = $page + 1; $query = mysql_query($sql_text); // Set up specified page $page_start = ($per_page * $page) - $per_page; $num_rows = mysql_num_rows($query); if ($num_rows = $per_page) { $num_pages = 1; } else if (($num_rows % $per_page) == 0) { $num_pages = ($num_rows / $per_page); } else { $num_pages = ($num_rows / $per_page) + 1; } $num_pages = (int) $num_pages; if (($page $num_pages) || ($page 0)) { } // // Now the pages are set right, we can // perform the actual displaying... $sql_text = $sql_text . LIMIT $page_start, $per_page; $query = mysql_query($sql_text); ? table border=1 align=center tr align=center valign=top bgcolor=#86B3E3 tdh3Plan/h3/td tdh3Domain/h3/td tdh3First Name/h3/td tdh3Last Name/h3/td tdh3Company/h3/td tdh3Email/h3/td tdh3User Name/h3/td tdh3Password/h3/td /tr ? //$query = mysql_query(SELECT * FROM customersWHERE $metode LIKE '%$search%' LIMIT 0, 30 ); while ($row = mysql_fetch_array($query)) {$plan=$row[plan]; $domaname=$row[domaname]; $fname=$row[fname]; $lname=$row[lname]; $company=$row[company]; $email=$row[email]; $cusername=$row[cusername]; $cpassword=$row[cpassword]; echo tr align='center'; print (tdstrong$plan/strong/tdtdstrong$domaname/strong/tdtdstr ong$fname/strong/td tdstrong$lname/strong/tdtdstrong$company/strong/tdtdstron g$email/strong/tdtdstrong$cusername/strong/tdtdstrong$cpass word/strong/tdbr); echo /tr; } echo /table; // Previous if ($prev_page) { echo a href=\$PHP_SELF?page=$prev_page\Prev/a; } // Page # direct links for ($i = 1; $i = $num_pages; $i++) { if ($i != $page) { echo a href=\$PHP_SELF?page=$i\$i/a; } else { echo $i ; } } // Next if ($page != $num_pages) { echo a href=\$PHP_SELF?page=$next_page\Next/a; } Best regards, Richard mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Links as a query point instead of form drop down box
Hi Laurie, If the data to be displayed was in a database, and each row of data corresponded to an auto incrementing id, you could reference by id number, which is a much better way of doing things via the GET method than messing around with long names. Assuming that you have two tables, one that contains the categories (with its own unique id, adn one which contains the elements of each category): table categories: idcategory 1Apples 2Pears 3Oranges table contents: idcat_idnamecontents 11Green applesetc etc 21Red Apples etc etc 31Exotic applesetc Then the contents page: ? $connection = //Connection details. $get_categories = @mysql_query(SELECT * FROM categories ORDER BY category DESC, $connection) or die (mysql_error()); while($row = mysql_fetch_array($get_categories)) { $id = $row['id']; $category = $row['category']; echo a href=\category.php?id= . $id . \ . stripslashes(htmlentities($category)) . /a; } ? The category page, where all the fruits are held: ? $connection = //Connection details. $get_contents = @mysql_query(SELECT * FROM contents WHERE cat_id = '$id' ORDER BY name DESC, $connection) or die (mysql_error()); while($row = mysql_fetch_array($get_contents)) { $id = $row['id']; $name = $row['name']; $contents = $row['contents']; echo stripslashes(htmlentities($name)) . BRBR; echo stripslashes(htmlentities($contents)); } ? Or you could combine the both: ? $connection = //Connection details. $get_categories = @mysql_query(SELECT * FROM categories ORDER BY category DESC, $connection) or die (mysql_error()); while($row = mysql_fetch_array($get_categories)) { $id = $row['id']; $category = $row['category']; echo a href=\category.php?id= . $id . \ . stripslashes(htmlentities($category)) . /a; echo UL; $get_contents = @mysql_query(SELECT * FROM contents WHERE cat_id = '$id' ORDER BY name DESC, $connection) or die (mysql_error()); while($row = mysql_fetch_array($get_contents)) { $name = $row['name']; $contents = $row['contents']; echo LI . stripslashes(htmlentities($name)) . BRBR; echo LI . stripslashes(htmlentities($contents)); } echo /UL; } ? The last example would give you something like: Apples: Green apples Green apples are greener than green. Red Apples Red apples are redder than red. Exotic apples Are, Exotic. Pears: Etc Of course, that won't look too pretty, but I leave the layout to you. Have a play, see how you get on :) James. Laurie Landry [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I understand how to use a dropdown box to make your selection in which that selection is the criteria to display a database content; but I was wondering how I can achieve a query by link. For example, if you went to index.html file where there is a php coding that generates the categories available (arrays) and outputs: a href=showdata.phpApples/a a href=showdata.phpOranges/a a href=showdata.phpBananas/a If you click on apples, it will send a query to the database to show all listings under the category apples. (SELECT category FROM FRUITS WHERE category=apples) how would I add the query criteria to the link? and how would I set up showdata to take the information from the selected link? thanks in advance, Laurie M. Landry lmlweb Design Development www.lmlweb.com [EMAIL PROTECTED] T: (604) 872-6915 F: (425) 732-1547 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] UGH
Neither will work. Think about it.. If you did 17 - 3 (17th May - 3rd June) - you get 14. But if you add 14 days from today, you get 31st May, which is clearly wrong. What if there are 30 days in the month instead of 31? Or 28? Or even more obscurely 29? You cannot rely on this method at all. What you need to do here is to get the distance between days in real terms. I suggest using mktime(); - that way you can subtract dates over a long timespan. ? $today = date(Y-m-d); list($year, $month, $day) = explode(-, $today); $date_today = mktime(0, 0, 0, $month, $day, $year); $school_out = mktime(0, 0, 0, 07, 21, 2001); $difference = $school_out - $date_today; $days = $difference / 86400; if ($date_today $school_out) { echo We're already on holiday!; } else { echo $days . days to go!; } ? Where $school_out = 21st July, 2001. 86400 is the number of seconds in a day. Things would get more complicated with hours and seconds, but you get the idea :) Note that in this instance, $difference / 86400 will always be an exact division. James Taylor, Stewart [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... ? $date = date (d); $math = 24 - $date; if ($date == 24); { '=' shoud be '==' echo FONT SIZE=4 FACE=ARIAL COLOR=#808080SCHOOL'S OUT FOR SUMMER!!! *guitar ballad*/font; } else { echo FONT SIZE=4 FACE=ARIAL COLOR=#808080Only $math days until school's out!!! w00p w00p!/font; } ? -Original Message- From: chris herring [mailto:[EMAIL PROTECTED]] Sent: 17 May 2001 09:56 To: [EMAIL PROTECTED] Subject: [PHP] UGH This is really bugging me. I don't see any reason why it shouldn't work, yet it doesn't. ? $date = date (d); $math = 24 - $date; if ($date = 24); { echo FONT SIZE=4 FACE=ARIAL COLOR=#808080SCHOOL'S OUT FOR SUMMER!!! *guitar ballad*/font; } else { echo FONT SIZE=4 FACE=ARIAL COLOR=#808080Only $math days until school's out!!! w00p w00p!/font; } ? any help is appreciated -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] UGH
In addition - if you did 3rd June as the end date - 17th May as today, 3 - 17, the original $days_to_go would be a minus number (What I meant to say in the first place Also, this would be better: if ($date_today $school_out) { echo We're already on holiday!; $new_difference = $date_today - $school_out; $days_gone = $new_difference / 86400; echo It's been . $days_gone . since we got outta there.; } else if ($date_today == $school_out) { echo Grab your coat, we're outta here today!; } else { echo $days . days to go!; } Need...moreCoffe James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problem with outputting date and time
Hi There, I had a similar problem because of BST (British Sumer Time). Have a look on Yahoo / Google etc for a site about Greenwich Mean Time, and find out the dates that the schemes take effect - I think it is March 25th to beginning or end of October. Then use a simple if statement. ? $hour = date(H); if ((date(m) 3) (date(d) 25) (date(m) 10) (date(d) 31)) { $hour = $hour - 1; } ? Hope that helps. James. Good Fella [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi All, I need help with a small problem. My website has many users from around the world, and they need to submit a form at a certain time (UK Time). Because of this, I need to display the UK Time on my website. I do this by putting this code: ?php echo gmdate(F jS Y, h:ia); ? There is nothing wrong with this code, except for when the clock changes (goes back/forward an hour). This means that this code is 1 hour behind the real UK Time at the moment. Is there any simple way of adding 1 hour onto this? It's extremely confusing as it's making users from around the globe late with their submissions. Thanks for your help and time SK _ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] need some ideas here...
Hi Christian, I have an account with f2s.com that I use for sampling scripts with - I set up a mailform yesterday after reading this, using mail() to send the email to myself. It got here - albeit 6am today (I sent it yesterday lunchtime) Perhaps you're using the mail() function incorrectly? James. Christian Dechery [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... My free-web-hosting (www.f2s.com) does not allow PHP to send emails... I've tried everything... the mail() function, my alternate function which calls popen(/usr/lib/sendmail -t) and even a script.cgi with '#!/usr/bin/php' and all that stuff... the mail simply won't go an mail() always returns false... I'm guessing there's no mail sending in this server... so what do I do? is it possible for me to call a script on another host from with a script and return something to it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Image Upload??
From phpinfo() on f2s.com upload_max_filesize 2M So, something like, @copy($file, /path/to . $file_name) or die (Blam, something's up!); should work - haven't got time to try it at the moment. James. What am I doing wrong here? Is there a way to get around the temporary folder? Tnx Brave Cobra -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Needing help hear
Hi Richard, I *always* get this word wrong, but here goes You need to concantenate (grimace), which means (simply) add to to the variable, using .= Modify your code slightly: ? $recipient = ; $result = @mysql_query($sql); $num_rows = mysql_num_rows($result); while($myrow = mysql_fetch_array($result)) { $email = $myrow['email']; $recipient .= $email . ,; } ? Notice the .= before $recipient = $email ? Also why, is the $num_rows in there? It's not being used for anything. If you might have blank emails in there, you could make good use of the num rows. ? $recipient = ; $result = @mysql_query($sql); $num_rows = mysql_num_rows($result); $x = 0; while($myrow = mysql_fetch_array($result)) { $email = $myrow['email']; if (isset($email)) { $recipient .= $email . ,; $x++; } } echo Email sent to . $x . number of people, out of . $num_rows . residing in the database.; ? Hope that helps, James. Richard Kurth [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am trying to pull all the e-mail out of the database and put them in a format like this [EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED] this is what I have now but I don't seam to be going in the right direction. Could somebody give me a hint $sql = SELECT email FROM customers; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); while ($myrow = mysql_fetch_array($result)){ $recipient=$myrow[email] . ,; } Best regards, Richard mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] detecting HTML tags
Hi Bill ? if (preg_match(/([\])([^\]{1,})*([\])/i, $string)) { echo Houston, we have a problem.; } ? James. bill [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Is there a way to detect the presence of HTML tags? I don't want them stripped out, I just want to know if a string contains them. I'm rolling my own mailing program and want it to detect the HTML if present and send it appropriately. kind regards, bill hollett -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: Re[2]: [PHP] Newbie redirect/variable question
Steve, The way you are doing things could leave yourself open with all kinds of problems - one of which is address spoofing. A better way would be to TEST the link against values in the database before updating the link with a hit and exiting. Have the URL's marked against an auto-incremented id: id: 23 name: Steve's page url: http://www.somewhere.com Url: redirect.php?id=23 redirect.php: ? $check = @mysql_query(SELECT url FROM links WHERE id = '$id', $connection); if (mysql_num_rows($check) != 0) { $update = @mysql_query(UPDATE links SET out = out + 1 WHERE id = '$id', $connection); while($row = mysql_fetch_array($check)) { $url = $row['url']; } header(location: $url); exit; } else { ? HTML HEAD TITLELink not found/TITLE /HEAD BODY No corresponding link found! /BODY /HTML ? } ? Much better that way, IMO. At present, if someone typed in a fake address, the database would attempt to update a non-existant entry You could go further, and log the IP of the user, and perhaps even set a cookie if you were totally paranoid about people repeatedly clicking their links so that they got more hits out. Have fun ;) James. Steve Wade [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Ahh - thanks - that's helped :-) (Line 9 was the http_referrer line) Now the only trouble is, it seems to still treat $fred as null. The passing line is from index.php: a href=redirect.php?fred=www.fusion.org.autest link/a Should this work? Thanks, Steve ~~~ Steve Wade Youth Outreach Coordinator Fusion Australia Ltd (Sydney North) ABN 26 001 273 105 +61 2 9477 1110 -Original Message- From: Adaran (Marc E. Brinkmann) [mailto:[EMAIL PROTECTED]] Sent: Thursday, 10 May 2001 22:20 To: [EMAIL PROTECTED] Subject: Re[2]: [PHP] Newbie redirect/variable question Hi Steve, Thursday, May 10, 2001, 1:39:36 PM, you wrote: Steve Ok - thanks - my new redirect.php is Steve ?php Steve if ($fred != ) { Steve # $statement = UPDATE links SET hits=hits+1 WHERE href=\$u\; Steve # mysql_query($statement); Steve Header(Location: $fred); Steve exit; Steve } else { Steve Header(Location: $HTTP_REFERRER); Steve exit; Steve } ? Steve I get the following message... Steve Warning: Cannot add header information - headers already sent by (output Steve started at /home/swadie/public_html/redirect.php:2) in Steve /home/swadie/public_html/redirect.php on line 9 Make sure you have NO Blanks or any other Text before the ?php ! ? has to be the first two characters in the file. Which line is line 9 ? --- EnjoY, Adaran ([EMAIL PROTECTED]) check http://www.adaran.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MAX_FILE_SIZE : warning
Jacob, When you upload a file, it appends a few of its own variables. One of them is size - assuming the file is a variable called $file: if ($file_size $max_size) { echo $file_name . was too big!; } Also, you could check for Mime types. if ($file_type != image/jpeg || $file_type != image/pjpeg) { echo We only like jpegs!; } As a footnote, 500Kb is 512000 bytes (1024 bytes in a Kb). James. When I set INPUT TYPE=hidden NAME=MAX_FILE_SIZE VALUE=50 and a user uploads a file bigger than 50 my script prints a warning. How can I use MAX_FILE_SIZE and avoid that warning so that I can print my own error message to the user ? :) Jacob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] appended with \
Magnus, $string = stripslashes($string); http://www.php.net/manual/en/function.stripslashes.php James. magnus lawrie [EMAIL PROTECTED] wrote in message 9cu11s$6k1$[EMAIL PROTECTED]">news:9cu11s$6k1$[EMAIL PROTECTED]... I am using a form to test posting a variable. If my variable looks like this in script post_var.php3 : stringinaaform then it comes out like this in recieve.php3 : \stringinaaform\ why? thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] date calculation
Gary, Yes. Check the manual for mktime(); and getdate(); http://www.php.net/quickref.php James Is there a way to do calculations with dates? Preferably ignoring weekends. Thanks, Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] date list
Jon, Try this ... I know the code could be trimmed down, but I wrote it this way for ease of reading. select name=Date ? $startday = 01; $startmonth = 01; $staryear = 01; $endday = 01; $endmonth = 07; $endyear = 01; $startperiod = mktime(0,0,0,$startmonth,$startday,$startyear); $endperiod = mktime(0,0,0,$endmonth,$endday,$endyear); while($startperiod = $endperiod) { $date = getdate($startperiod); $year = $date['year']; $month = $date['mon']; $day = $date['mday']; echo option value=\$year-$month-$day\; echo $month/$day/$year; echo /option\n; $startperiod = $startperiod + 86400; } ? /select Basically just uses mktime() and getdate() The 86400 is the number of seconds in the day, and the option value is set to return in the format -MM-DD (that format's used a lot in MySQL tables). Have fun ;) James. 01/01/01-01/07/01 01/08/01-01/14/01 01/15/01-01/21/01 etc etc till the end of 2002 and further in the future eventually I'd like to make PHP generate this for me so I don't have to handcode it for each year in the future. I've looked at the date/time functions and I'm a bit confused. Any help would be appreciated. Thanks! Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] redirection to another page function
One thing that doesn't seem to have been considered is the use of the refresh meta tag. Whilst it depends on whether or not the browser is archaic (and let's face it, most people nowadays seem to be running at least version 4 of either IE or Netscape), it's something that can't be turned off (at least to my knowledge, I could be wrong) and workarounds can be supplied for instances when the browser doesn't accept the tag. This doesn't hinder programming too much, as you don't have to worry about sending output after headers, nor whether or not the browser has javascript enabled. Personally, I prefer to use the header() function, and it's ages since I've used this meta tag, though it's worth keeping in mind that old techniques can still be useful ;) META HTTP-EQUIV=Refresh CONTENT=1;url=page.php James. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Update All fields?
Hi There, I currently have a MySQL table, with around 700 populated rows in it. I'd like to know if there's a quick and easy way to update one column across all of the rows in the database. I shouldn't imagine it's a difficult job, but I'm having a mental block :) Thanks in advance. -- James -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Reading specific data from a .txt file into PHP
Hi all, I'm attempting to write a weather script, which will display weather conditions for areas in the UK. I have the data I need, which is stored in a file on another server. The data comes in the format: 2001/01/16 13:50 SCT010 BKNDPIP WYXWE Q1012 2001/01/16 13:46 CYGL 161346Z 34004KT 15SM -SN BKN011 BKN030 RMK SF6SC1 Where the first four characters below the dates are 4 letter codes for cities (the script will be using metar(aviation) readings) and the rest is the actual weather information. The trouble is, that there are about 3000 cities in the text file. I'm assuming that I fill use fopen(); and fread(); to open and read the files, but does anyone know of a way of singling out one line (say: CYGL 161346Z 34004KT 15SM -SN BKN011 BKN030 RMK SF6SC1 ) from the whole text file? Like if a variable, $city = CYGL, is it possible to then go to that one line in the text file and read all the information from just one line? I'm pretty confident I could then split the information up into readable variable using the split(); function :) Thanks in advance for any help you might be able to give, James. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Reading specific data from a .txt file into PHP
Glen Scott [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... James, The trouble is, that there are about 3000 cities in the text file. I'm assuming that I fill use fopen(); and fread(); to open and read the files, but does anyone know of a way of singling out one line (say: CYGL 161346Z 34004KT 15SM -SN BKN011 BKN030 RMK SF6SC1 ) from the whole text file? Like if a variable, $city = CYGL, is it possible to then go to that one line in the text file and read all the information from just one line? I'm pretty confident I could then split the information up into readable variable using the split(); function :) Assuming the first field (i.e. CYGL) is unique, just read each line and check using a regular expression whether it matches the city you require. If it matches, you can stop reading the file and do whatever you need to do with the line. That's just it, I don't know how to 'read' each line and stop And the first field is unique Sorry to be such a dummy, I'm still very new to PHP, and have never really used Perl either ;) By 'using a regular expression', do you mean that something as simple as an "if" statement might do the job? Can you help any further? Thanks for getting me this far. James. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]