Jump to content

Is there anything wrong with MySQL UPDATE statement ?


mistypotato

Recommended Posts

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());

??

 

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

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!

??

 

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?" ;)

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 ??????

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.