jaylearning Posted May 11, 2007 Share Posted May 11, 2007 Hi! and thanks for looking, the problem is that when i edit and title it still stays the same im still learning please help me. thanks alot. <? //connect to mysql //change user and password to your mySQL name and password mysql_connect("localhost","root",""); //select which database you want to edit mysql_select_db("php"); //If cmd has not been initialized if(!isset($cmd)) { //display all the php $result = mysql_query("select * from php order by id"); //run the while loop that grabs all the php scripts while($r=mysql_fetch_array($result)) { //grab the title and the ID of the php $title=$r["title"];//take out the title $id=$r["id"];//take out the id //make the title a link echo "<a href='edit.php?cmd=edit&id=$id'>$title - Edit</a>"; echo "<br>"; } } ?> <? if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") { if (!isset($_POST["submit"])) { $id = $_GET["id"]; $sql = "SELECT * FROM php WHERE id=$id"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ?> <form action="edit.php" method="post"> <input type=hidden name="id" value="<?php echo $myrow["id"] ?>"> Title:<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["title"] ?>" SIZE=30> <br> <input type="hidden" name="cmd" value="edit"> <input type="submit" name="submit" value="submit"> </form> <? } if ($_POST["$submit"]) { $title = $_POST["title"]; $sql = "UPDATE php SET title='$title' WHERE id=$id"; //replace php with your table name above $result = mysql_query($sql); echo "Thank you! Information updated."; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50887-mysql-row-dont-edit/ Share on other sites More sharing options...
StormTheGates Posted May 11, 2007 Share Posted May 11, 2007 Do this: $result = mysql_query($sql) or die(mysql_error()) That will show you the error that your update is generating and to why its not updating. Then it should be easy to find the cause Quote Link to comment https://forums.phpfreaks.com/topic/50887-mysql-row-dont-edit/#findComment-250285 Share on other sites More sharing options...
Psycho Posted May 11, 2007 Share Posted May 11, 2007 Here's another problem: if ($_POST["$submit"]) Should be: if ($_POST["submit"]) Quote Link to comment https://forums.phpfreaks.com/topic/50887-mysql-row-dont-edit/#findComment-250290 Share on other sites More sharing options...
jaylearning Posted May 11, 2007 Author Share Posted May 11, 2007 thanks a million for helping me out. im really greatful you helped me. Quote Link to comment https://forums.phpfreaks.com/topic/50887-mysql-row-dont-edit/#findComment-250291 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.