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

Link to comment
Share on other sites

??

 

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
Share on other sites

??

 

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.