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()); Quote Link to comment Share on other sites More sharing options...
revraz Posted August 12, 2008 Share Posted August 12, 2008 I'm guessing because $nncustid is empty Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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! Quote Link to comment 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?" Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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 ?????? Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.