mistypotato Posted August 12, 2008 Share Posted August 12, 2008 Hi, I have two MySQL statements. The first one works perfectly (Insert1) but the second (Update2) does not seem to update the table called boating.customers. Can you see why? mysql_connect("localhost","admin","123456") or die ("Unable to connect to MySQL server."); $db = mysql_select_db("boatingcustomers") or die ("Unable to select requested database."); $Insert1 = mysql_query("INSERT INTO boatingcustomers.ratingshistory (vote,userid,voteid,date,ip) values ('$vote_sent','$nncustid','$id_sent',Now(),'$ip_num')") or die("Insert error:" . mysql_error()); $Update2 = mysql_query("UPDATE boatingcustomers.customers SET voted='Y' WHERE Custnum='$nncustid'") or die("Insert error:" . mysql_error()); Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/ Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 I'm guessing because $nncustid is empty Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615021 Share on other sites More sharing options...
mistypotato Posted August 12, 2008 Author Share Posted August 12, 2008 it works properly on the first part so I assume its still available for the 2nd statement? I thought maybe the way I was writing 'Y' was wrong Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615028 Share on other sites More sharing options...
void Posted August 12, 2008 Share Posted August 12, 2008 structure of the `customers` table would be helpful. Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615030 Share on other sites More sharing options...
mistypotato Posted August 12, 2008 Author Share Posted August 12, 2008 TABLE CUSTOMERS voted Varchar(1) Binary Default value=NULL Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615032 Share on other sites More sharing options...
Barand Posted August 12, 2008 Share Posted August 12, 2008 That structure reply is as much use as a chocolate teapot. In the INSERT you set userid to $nncustid. In the UPDATE you try to update the row WHERE Custnum = $nncustid. Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615039 Share on other sites More sharing options...
mistypotato Posted August 12, 2008 Author Share Posted August 12, 2008 ?? That is the structure of that field. What difference does it make what the rest of the table's structure is? Your response makes absolutely no sense. There are two totally different table involved. I'm Updating One...Inserting into another, the only trouble is the UPDATE line which uses one field (voted) in the customers table Besides if you like chocolate, a chocolate teapot is a great thing Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615045 Share on other sites More sharing options...
void Posted August 12, 2008 Share Posted August 12, 2008 are you sure there's a record with the id you're trying to update? does field `Custnum` have to be capitalized? Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615048 Share on other sites More sharing options...
mistypotato Posted August 12, 2008 Author Share Posted August 12, 2008 VOID... YOU sir / maam are a thinker !!!! That is exactly what was wrong ;-) I was simply supplying a customer number that did not exist. Thank you for your intelligent and useful reply ! (and pleasant I may add) hehe MANY thanks! Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615053 Share on other sites More sharing options...
peasepud Posted August 12, 2008 Share Posted August 12, 2008 ?? That is the structure of that field. What difference does it make what the rest of the table's structure is? Your response makes absolutely no sense. There are two totally different table involved. I'm Updating One...Inserting into another In would have thought it makes a shedload of difference, if you're using different variable types for customer id in the table to what you're passing through then that would explain it. Personally, if I had raised this issue and was asked that last question I would have supplied not only the full structure of the table but also an example of the URL showing a customer number being passed over, otherwise its as much use as going on a medical forum and saying "I dont feel well, whats wrong with me?" Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615054 Share on other sites More sharing options...
Barand Posted August 12, 2008 Share Posted August 12, 2008 Sorry, I misread. Thought they both referenced the table called boating.customers. Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615063 Share on other sites More sharing options...
mistypotato Posted August 12, 2008 Author Share Posted August 12, 2008 VOID, You are the best ! I'm amazed how easy you made that seem hehe Thanks again Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615065 Share on other sites More sharing options...
mistypotato Posted August 12, 2008 Author Share Posted August 12, 2008 No worries. I'm first to admit I don't really know much about php but I'm trying and positive support would be appreciated. This is a very good place to get info. A lot of very nice people here. I don't even know how I would get the entire structure of the table here ?????? Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615070 Share on other sites More sharing options...
Barand Posted August 12, 2008 Share Posted August 12, 2008 if you don't have Mysql Query Browser (download from Mysql.com) or phpmyadmin use the mysql command line and enter the SQL command describe tablename; E.G. [pre] mysql> describe pupil; +------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+----------------+ | pupilID | int(11) | NO | PRI | NULL | auto_increment | | pupil_name | varchar(30) | YES | | NULL | | | houseID | int(11) | YES | | NULL | | +------------+-------------+------+-----+---------+----------------+[/pre] Link to comment https://forums.phpfreaks.com/topic/119382-is-there-anything-wrong-with-mysql-update-statement/#findComment-615093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.