Re: [PHP] PHP/MySQL help?
Hi Steven, On Sunday 12 January 2003 23:58, Steven M wrote: include 'db.php'; $result = mysql_query(SELECT newtest FROM users WHERE 14 = '$0'); list($number) = mysql_fetch_row($result); Here you are closing your conenction to the MySQL-Server: mysql_close(); if($number==0) But here you need it again: {mysql_query(UPDATE users SET points = '$+2' WHERE 14 = '$0'); mysql_query(UPDATE users SET newtest = '$1' WHERE newtest = '$0'); So remove the mysql_close() if it don't work: Post the error message! johannes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/MySQL help?
Hi Johannes Thanks for the help. I have taken out the mysql_close() and it looks like it is submitting ok (ie no error messages) but it is not updating the database when i check it. Any ideas? Thanks. Steven Johannes Schlueter [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi Steven, On Sunday 12 January 2003 23:58, Steven M wrote: include 'db.php'; $result = mysql_query(SELECT newtest FROM users WHERE 14 = '$0'); list($number) = mysql_fetch_row($result); Here you are closing your conenction to the MySQL-Server: mysql_close(); if($number==0) But here you need it again: {mysql_query(UPDATE users SET points = '$+2' WHERE 14 = '$0'); mysql_query(UPDATE users SET newtest = '$1' WHERE newtest = '$0'); So remove the mysql_close() if it don't work: Post the error message! johannes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP/MySQL help?
Hmm from your code below: FROM users WHERE 14 = '$0' What is 14 it isn't a field I would hope!! Timothy Hitchens (HiTCHO) Open Platform Consulting e-mail: [EMAIL PROTECTED] -Original Message- From: Steven M [mailto:[EMAIL PROTECTED]] Sent: Monday, 13 January 2003 9:28 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] PHP/MySQL help? Hi Johannes Thanks for the help. I have taken out the mysql_close() and it looks like it is submitting ok (ie no error messages) but it is not updating the database when i check it. Any ideas? Thanks. Steven Johannes Schlueter [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi Steven, On Sunday 12 January 2003 23:58, Steven M wrote: include 'db.php'; $result = mysql_query(SELECT newtest FROM users WHERE 14 = '$0'); list($number) = mysql_fetch_row($result); Here you are closing your conenction to the MySQL-Server: mysql_close(); if($number==0) But here you need it again: {mysql_query(UPDATE users SET points = '$+2' WHERE 14 = '$0'); mysql_query(UPDATE users SET newtest = '$1' WHERE newtest = '$0'); So remove the mysql_close() if it don't work: Post the error message! johannes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/MySQL help?
I thought i read somewhere that you could refer to the field by number. Was i wrong? It doesn't seem to make a difference anyway. It still doesn't work. Here's the code with words instead of numbers. I'd be grateful if you could let me know if there are any obvious errors. Best wishes. Steven M include 'db.php'; $result = mysql_query(SELECT newtest FROM users WHERE newtest = '$0'); list($number) = mysql_fetch_row($result); if($number==0) {mysql_query(UPDATE users SET points = '$+2' WHERE newtest = '$0'); mysql_query(UPDATE users SET newtest = '$1' WHERE newtest = '$0'); header(Location: redirect1.php); } elseif($number==1) { header(Location: redirect2.php); } else { header(Location: error.php); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP/MySQL help?
You can't use numbers as vars: $1 etc are illegal syntax for PHP Timothy Hitchens (HiTCHO) Open Platform Consulting e-mail: [EMAIL PROTECTED] -Original Message- From: Steven M [mailto:[EMAIL PROTECTED]] Sent: Monday, 13 January 2003 10:04 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] PHP/MySQL help? I thought i read somewhere that you could refer to the field by number. Was i wrong? It doesn't seem to make a difference anyway. It still doesn't work. Here's the code with words instead of numbers. I'd be grateful if you could let me know if there are any obvious errors. Best wishes. Steven M include 'db.php'; $result = mysql_query(SELECT newtest FROM users WHERE newtest = '$0'); list($number) = mysql_fetch_row($result); if($number==0) {mysql_query(UPDATE users SET points = '$+2' WHERE newtest = '$0'); mysql_query(UPDATE users SET newtest = '$1' WHERE newtest = '$0'); header(Location: redirect1.php); } elseif($number==1) { header(Location: redirect2.php); } else { header(Location: error.php); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/MySQL help?
Oops...many thanks for that. Sorry, i am extremely new to this. Best wishes. Steven M -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP/mySQL help or advice
There are a few PHP calendars: http://www.cascade.org.uk/software/php/calendar/index.php for example, that you can start from. It should be relatively easy then to write a small table that contains just one field: Date (datetime) All you do is insert a row in the db for each day that is booked and then whenever you have to check just hit the database: if there is a row corresponding to the day you're checking, then the day is booked, otherwise it isn't. This is kind of the short version, but hopefully it should give you enough to get going! Cheers, Marco On Sun, 2002-10-13 at 07:48, Ray Healy (Data Net Services) wrote: Hi All I have been trying to write a database and scripts for a calendar that shows which days are booked and have failed at each point. What i would like it to do is to show a calendar which have the dates that are booked in a cell which are colour coded (say red) when it is unavailable and say white when available. The admiministartor should be able to enter multiple dates at a time (say a holiday is booked for 5 days). perhaps a section for nortes that is only available for admin use only would be handy. An option to view 2 months at a time or perhaps the whole year would also be nice. I have downloaded various scripts and tried to write my own but I cannot seem to be able to enter multiple dates or colour code the output. Can anyone help me or perhaps someone already has a script database that does this and would be willing to share. Otherwise it there a script already out there that will do this - all the one that I can find seem to do too much by allowing multiple users and storing a lot more data which is something I do nort need. Any help would be appreciated as I am tearing my hair out at the moment. Thanks for your time Ray Healy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP+MySQL=Help(?)
Hi, from this command line test: select imglocation,height,width from img where imgname='alfstag1' it looks to me like your imgname field is *characters* rather than *numbers*. when ever I'm doing something like this (eg WHERE firstName=justin), I do it with a LIKE statement, rather than with a =. example: $query = SELECT imglocation,height,width FROM img WHERE imgname LIKE \$getimg\; So, I'd recommend giving that a try. From my understanding (limited) of MySQL, use = in the case of $id=2, and LIKE in the case of firstName LIKE justin. 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]
Re: [PHP] PHP+MySQL=Help(?)
On Wednesday 31 October 2001 02:32 am, you wrote: So, I'd recommend giving that a try. From my understanding (limited) of MySQL, use = in the case of $id=2, and LIKE in the case of firstName LIKE justin. Um...you *can* do that, but I don't think you want to. Using LIKE means that MySQL has to do a lot more searching on all your database records. Instead of searching for an exact match, where it can look at things like string length, first characters and other simple criteria, it now has to evaluate the entire contents of the field in case there's a possible match somewhere in the string. Much, much slower. So, yes it works, but you pay a performance price for it. --kurt -- 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] PHP+MySQL=Help(?)
. Thanks to Kurt and Justin for the help offered on this simple (now that it is working) problem. I do not know where my stumbling block was but after a good nights rest and some coffee this morning I have this and the GetImageSize function incorporated.. I will list the code incase someone finds problems or a simpler way to go with it but it does seem to work well (at least on the local host) ? mysql_connect('localhost')or die (Could not connect); mysql_select_db('img760')or die (Could not select database); $results = mysql_query (select imglocation from img where imgname like '$getimg'); $row = mysql_fetch_array($results); $imglocation = $row['imglocation']; $size = GetImageSize ($imglocation); ? Display within the html doc is: img src=? echo $imglocation ? ? echo $size[3]; ? Again thanks for all of your patience and help Mike -- 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] PHP+MySQL=Help(?)
. Thank you for the heads up on using like. I was wondering since there will be 2 similar variables from each page var1 var2 (identical except for the number). I programmed in DataFlex for about 6 years back in the late 80's early 90's but have not done anything db wise in over 8 years I still do not know where the problem was (maybe syntax or spelling) Again, thank you for all of your help... Mike Kurt Lieber [EMAIL PROTECTED] wrote in message E15yxVD-0005ls-00@z8">news:E15yxVD-0005ls-00@z8... On Wednesday 31 October 2001 02:32 am, you wrote: So, I'd recommend giving that a try. From my understanding (limited) of MySQL, use = in the case of $id=2, and LIKE in the case of firstName LIKE justin. Um...you *can* do that, but I don't think you want to. Using LIKE means that MySQL has to do a lot more searching on all your database records. Instead of searching for an exact match, where it can look at things like string length, first characters and other simple criteria, it now has to evaluate the entire contents of the field in case there's a possible match somewhere in the string. Much, much slower. So, yes it works, but you pay a performance price for it. --kurt -- 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] PHP+MySQL=Help(?)
On Wednesday 31 October 2001 07:45 am, turtle wrote: img src=? echo $imglocation ? ? echo $size[3]; ? Glad we could help. Also, you can re-write the above so you don't have to define two sets of ?php ? tags by doing the following: ?php print img src=\$imglocation\ $size[3]; ? Not a big deal here, but if you start writing multiple lines of HTML code, you probably don't want to enclose each PHP variable in its own set of ?php ? tags. Also, I tried to send you a couple suggestions off-list last night, but your email bounces -- I'm guessing the new owner of netobjects doesn't have their mail server set up to accept the correct email address. Just FYI. --kurt -- 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] PHP+MySQL=Help(?)
. Thank you Kurt, The day for the server to be move from Cal to Fla is the 31st (today) I would image that it is somewhere in transit at the present time... Will send you an email with another address you can respond to... Thanks for all of your help Mike Kurt Lieber [EMAIL PROTECTED] wrote in message E15yy3N-0005qE-00@z8">news:E15yy3N-0005qE-00@z8... On Wednesday 31 October 2001 07:45 am, turtle wrote: img src=? echo $imglocation ? ? echo $size[3]; ? Glad we could help. Also, you can re-write the above so you don't have to define two sets of ?php ? tags by doing the following: ?php print img src=\$imglocation\ $size[3]; ? Not a big deal here, but if you start writing multiple lines of HTML code, you probably don't want to enclose each PHP variable in its own set of ?php ? tags. Also, I tried to send you a couple suggestions off-list last night, but your email bounces -- I'm guessing the new owner of netobjects doesn't have their mail server set up to accept the correct email address. Just FYI. --kurt -- 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] PHP+MySQL=Help(?)
On Tuesday 30 October 2001 10:13 am, turtle wrote: ? $link = mysql_connect('localhost')or die (Could not connect); mysql_select_db('img760')or die (Could not select database); $query = select ('imglocation','height','width') from img where imgname=$getimg; $imglocation = 'imglocation'; $height = 'height'; $width = 'width'; ? You need to read the manual on the mysql functions. Specifically, functions like mysql_fetch_array, mysql_fetch_row, mysql_result. You're setting $imglocation to a string, not a returned result from mysql. You need to use one of the three functions I mentioned to retun an actual mysql result. --kurt -- 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] PHP+MySQL=Help(?)
. No reading that section of the manual did me no good. I do not understand other than I cannot store the results as a variable. Is there any of what I have done that is usable? A recommendation for a book that covers this would be helpful... the manual on this area is way to abbreviated for someone who has only used PHP for 2 weeks. Mike Kurt Lieber [EMAIL PROTECTED] wrote in message E15ydj6-0003KZ-00@z8">news:E15ydj6-0003KZ-00@z8... On Tuesday 30 October 2001 10:13 am, turtle wrote: ? $link = mysql_connect('localhost')or die (Could not connect); mysql_select_db('img760')or die (Could not select database); $query = select ('imglocation','height','width') from img where imgname=$getimg; $imglocation = 'imglocation'; $height = 'height'; $width = 'width'; ? You need to read the manual on the mysql functions. Specifically, functions like mysql_fetch_array, mysql_fetch_row, mysql_result. You're setting $imglocation to a string, not a returned result from mysql. You need to use one of the three functions I mentioned to retun an actual mysql result. --kurt -- 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] PHP+MySQL=Help(?)
On Tuesday 30 October 2001 11:58 am, turtle wrote: No reading that section of the manual did me no good. I do not understand other than I cannot store the results as a variable. yes, you can. Is there any of what I have done that is usable? yes, there is. see below. It's probably not solid enough to cut 'n' paste, but it at least shows you how to get return results from mysql. A recommendation for a book that covers this would be helpful... the manual on this area is way to abbreviated for someone who has only used PHP for 2 weeks. Beginning PHP4 by Wrox ? $link = mysql_connect('localhost')or die (Could not connect); mysql_select_db('img760')or die (Could not select database); $query = select imglocation,height,width from img where imgname=$getimg; //you haven't defined $getimg anywhere that I can see // also need to enclose it in quotes: '$getimg' $results = mysql_fetch_array($query); //new line $imglocation = $reults['imglocation']; $height = $results['height']; $width = $results['width']; ? -- 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] PHP+MySQL=Help(?)
. It is starting to make sense. I see the correlation between the manual example and the code you show. Surprisingly (and equally confusing) the book I have also uses a while loop with mysql_fetch_array to display a list. The getimg variable comes in from the javasript function on the other page embedded in the url: window.open('../../assets/img760/img.php?getimg=alfstag1') the variable content is the field (imgname) that I use to find the record. I have been passing all of the variables manually via the url but it would be best if I used a database as there are around 400 to show and changes in a db are easier than in the html head. This may be the problem as I now get supplied argument not valid mysql result on this line. $query = select imglocation,height,width from img where imgname='$getimg'; Thank you for taking the time with me on this. I will see if I can find the remaining problems and get to coding the 400+ pages that I need to get this into. It looks like I might be able to use the GetImageSize function to do this same thing? maybe? All I am doing is getting the location (url) of an image and its height and width for an img src= statement. maybe I am making this into a bigger job than necessary?? I think I have been working on it too long today and I need a long walk. Anyway, thank you again for taking the time and for the book recommendation. Mike Kurt Lieber [EMAIL PROTECTED] wrote in message E15yfMr-0003fP-00@z8">news:E15yfMr-0003fP-00@z8... On Tuesday 30 October 2001 11:58 am, turtle wrote: No reading that section of the manual did me no good. I do not understand other than I cannot store the results as a variable. yes, you can. Is there any of what I have done that is usable? yes, there is. see below. It's probably not solid enough to cut 'n' paste, but it at least shows you how to get return results from mysql. A recommendation for a book that covers this would be helpful... the manual on this area is way to abbreviated for someone who has only used PHP for 2 weeks. Beginning PHP4 by Wrox ? $link = mysql_connect('localhost')or die (Could not connect); mysql_select_db('img760')or die (Could not select database); $query = select imglocation,height,width from img where imgname=$getimg; //you haven't defined $getimg anywhere that I can see // also need to enclose it in quotes: '$getimg' $results = mysql_fetch_array($query); //new line $imglocation = $reults['imglocation']; $height = $results['height']; $width = $results['width']; ? -- 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] PHP+MySQL=Help(?)
On Tuesday 30 October 2001 02:53 pm, you wrote: It is starting to make sense. I see the correlation between the manual example and the code you show. Surprisingly (and equally confusing) the book I have also uses a while loop with mysql_fetch_array to display a list. You would use a while loop if/when you have multiple records to retrive. From your original code example, it seemed as though you would only have one record. (though, for safety's sake, you should code a LIMIT into your sql statement) This may be the problem as I now get supplied argument not valid mysql result on this line. $query = select imglocation,height,width from img where imgname='$getimg'; Two things to try: 1. Run that exact query on a mysql command line, substituting whatever variable name you're trying to pass in the URL. Often times, I find that I tihnk I have a PHP problem when, in fact, I screwed up my query syntax somewhere. 2. Explicitly define $getimg as something you know to be a valid image. If that works, then you know it isn't getting passed from the url properly. It looks like I might be able to use the GetImageSize function to do this same thing? maybe? All I am doing is getting the location (url) of an image and its height and width for an img src= statement. maybe I am making this into a bigger job than necessary?? I think I have been working on it too long today and I need a long walk. Actually, yes you can. $myImgSize = getImageSize('/unix/path/to/my/file.jpg'); should return the image sizes in an array. You should then be able to do something like: img src=file.jpg $myImgSize[3] Which should automatically include height/width parameters. (see this function on the php site for more info -- also, that's untested, off-the-cuff code I just wrote. Might not work perfectly. :) --kurt -- 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] PHP+MySQL=Help(?)
Kurt Lieber You would use a while loop if/when you have multiple records to retrive. From your original code example, it seemed as though you would only have one record. (though, for safety's sake, you should code a LIMIT into your sql statement) Yes I only need one image location with height and width from the db file This may be the problem as I now get supplied argument not valid mysql result on this line. $query = select imglocation,height,width from img where imgname='$getimg'; Two things to try: 1. Run that exact query on a mysql command line, substituting whatever variable name you're trying to pass in the URL. Often times, I find that I tihnk I have a PHP problem when, in fact, I screwed up my query syntax somewhere. Doing a command line query at a mysql prompt brings back the correct data select imglocation,height,width from img where imgname='alfstag1' returns: ./alf_760stag1.jpg (the image location) 544 (the height) 760 (the width) 2. Explicitly define $getimg as something you know to be a valid image. If that works, then you know it isn't getting passed from the url properly. It looks like I might be able to use the GetImageSize function to do this same thing? maybe? All I am doing is getting the location (url) of an image and its height and width for an img src= statement. maybe I am making this into a bigger job than necessary?? I think I have been working on it too long today and I need a long walk. Actually, yes you can. $myImgSize = getImageSize('/unix/path/to/my/file.jpg'); should return the image sizes in an array. You should then be able to do something like: img src=file.jpg $myImgSize[3] Which should automatically include height/width parameters. (see this function on the php site for more info -- also, that's untested, off-the-cuff code I just wrote. Might not work perfectly. :) --kurt I found the GetImageSize while digging around the manual and tried to work it in without success. I have so far this evening re-written this with separate mysql_connect, mysql_select_db, and mysql_query functions and tested after each and that is as far as I can get without errors. I have tried mysql_fetch_array, mysql_fetch_object, and mysql_fetch_row... all have failed for some reason I am testing with an if (variable) set message then echo each message in the body... Here is a URL of a page where I pass the same variables manually and use them in the popup to give you an idea of what I am trying do to with a database holding this info http://www.bronze-gallery.com/French_Sculptors/Alfred_Barye/Stag_Scratching/ stag_scratching.html click on either image to get to the php popup this declares and passes the 3 variables in the url. so far the light bulb has not clicked on. The php4 book you recommended is on order Mike -- 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]