Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed assistance with a php mysql UPDATE statement tutorial please
    primarykey
    data
    text
    <p>Trying to follow a tutorial, but i get a database error on line six of the executable php file (second code below)</p> <pre><code> &lt;?php mysql_connect("localhost","root","") or die("Error: ".mysql_error()); //add your DB username and password mysql_select_db("beyondmotors");//add your dbname $sql = "select * from `TestTable` where ID = 1"; $query = mysql_query($sql); while ($row = mysql_fetch_array($query)){ $id = $row['ID']; $fname = $row['FName']; $lname = $row['LName']; $phone = $row['PHON']; //we will echo these into the proper fields } mysql_free_result($query); ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Edit User Info&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="updateinfo.php" method="post"&gt; userid:&lt;br/&gt; &lt;input type="text" value="&lt;?php echo $id;?&gt;" name="id" disabled/&gt; &lt;br/&gt; Last Name:&lt;br/&gt; &lt;input type="text" value="&lt;?php echo $fname;?&gt;" name="fname"/&gt; &lt;br/&gt; Last Name:&lt;br/&gt; &lt;input type="text" value="&lt;?php echo $lname;?&gt;" name="lname"/&gt; &lt;br/&gt; Phone Number:&lt;br/&gt; &lt;input type="text" value="&lt;?php echo $phone;?&gt;" name="phon"/&gt; &lt;/br&gt; &lt;input type="submit" value="submit changes"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and here is the executable</p> <pre><code> &lt;?php mysql_connect("localhost","root","") or die("Error: ".mysql_error()); //add your DB username and password mysql_se lect_db("beyondmotors");//add your dbname //get the variables we transmitted from the form $id = $_POST['']; $fname = $_POST['fname']; $lname = $_POST['lname']; $phon = $_POST['phon']; //replace TestTable with the name of your table $sql = "UPDATE `TestTable` SET `FName` = '$fname',`LName` = '$lname', `PHON` = '$phon' WHERE `TestTable`.`ID` = '$id' LIMIT 1"; mysql_query($sql) or die ("Error: ".mysql_error()); echo "Database updated. &lt;a href='editinfo.php'&gt;Return to edit info&lt;/a&gt;"; ?&gt; </code></pre> <p>everything is good until i hit submit changes; than i get error on line 6. I'm new to database so please be specific if possible. Thank you! also if anyone could point me to a similar, "working" tutorial that would help ALOT! </p> <p>trying to follow this tutorial: <a href="http://teamtutorials.com/web-development-tutorials/editing-mysql-data-using-php" rel="nofollow">http://teamtutorials.com/web-development-tutorials/editing-mysql-data-using-php</a></p> <p>i'm using wamp server, so the database log in is correct. I mean it displays the data, just doesn't edit it.. The error i'm getting is :</p> <p>Notice: Undefined index: ID in C:\wamp\www\test\updateinfo.php on line 6</p> <p>i get that even if i change post to $id = $_POST['ID'];</p> <p>Ok I changed the $_POST['']; to $_POST['id']; , still had the same error.</p> <p>Than I read online to add a @ to the front so now it looks like this: @$_POST['id'];</p> <p>That too off all the errors. but not my data base is not been updated. Everything goes through with no errors but no data is been changed??</p> <p>Also when i tried to remove backticks I get this error:</p> <p>Parse error: syntax error, unexpected T_STRING in C:\wamp\www\test\updateinfo.php on line 12</p> <p>So i left them the way they were...</p> <p>Could it be because i'm using a local server? This should be all simple not sure what i'm doing wrong here.. I mean i literary copied everything over from the tutorial. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload