Like this:

$result = mysql_query ("UPDATE StudentInfo SET StudentNumber= '$StudentNumber', FirstName='$FirstName', LastName='$LastName', EmailAddr='$EmailAddr', PhoneNumber='$PhoneNumber' WHERE recordID ='$RecordID'");

or is this better

$query_str = "UPDATE StudentInfo SET StudentNumber= $StudentNumber, FirstName=$FirstName, LastName=$LastName, EmailAddr=$EmailAddr, PhoneNumber=$PhoneNumber WHERE recordID=$RecordID";

$result = mysql_query($query_str);
if (!$result) {
    die('Invalid query: ' . mysql_error());

with the single quotes added

Checking for errors is always recommended.

Ok,

I think this is best

$result = "UPDATE StudentInfo SET StudentNumber= '$StudentNumber', FirstName='$FirstName', LastName='$LastName', EmailAddr='$EmailAddr', PhoneNumber='$PhoneNumber' WHERE recordID ='$RecordID'" or die(mysql_error());
$query=mysql_query($result);

However it runs as if it has updated however the data does not change?!?!

Any ideas?

You really need to be less sloppy, the code should be:

$query = "UPDATE StudentInfo SET StudentNumber= '$StudentNumber', FirstName='$FirstName', LastName='$LastName', EmailAddr='$EmailAddr', PhoneNumber='$PhoneNumber' WHERE recordID ='$RecordID'";
$result = mysql_query($query) or die(mysql_error());
commented: brought a smile to my face +14

When i run that i get

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'recordID'] ?>'' at line 1

Try this, and show the output.

$query = "UPDATE StudentInfo SET StudentNumber= '$StudentNumber', FirstName='$FirstName', LastName='$LastName', EmailAddr='$EmailAddr', PhoneNumber='$PhoneNumber' WHERE recordID ='$RecordID'";
$result = mysql_query($query) or die(mysql_error() . '<br/>' . $query);
commented: Thanks for your help +0

I get the follwing:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'recordID'] ?>'' at line 1

UPDATE StudentInfo SET StudentNumber= 'M00259315', FirstName='Jay', LastName='Green ', EmailAddr='jg@mdx.ac.uk', PhoneNumber='02086649985 ' WHERE recordID =''

As you can see, the record ID is empty, so probably not passed correctly by your form. Check that your form is created correctly.

I have this to pass the recordID variable to updateRecord.php

<input name="recordID" type="hidden" id="recordID" value="<?=$row['recordID'] ?>" />

Suntax look ok?

Check your output. If the ID isn't there, it's wrong. I prefer long tags:

<input name="recordID" type="hidden" id="recordID" value="<?php echo $row['recordID']; ?>" />

ITS WORKING!!!!

im not quite sure what i did but it is working.

Thanks so much. Is ther a thank button or anything?

You can mark the thread solved (recommended), you can upvote a reply, or you can upvote with a comment (adds reputation).

Upvoted and commented. I will mark as solved

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.