canox Posted March 17, 2008 Share Posted March 17, 2008 Hi all, So I have this script. Basically its form that connects to the database insterts rows in the databse onto the form. The user can change the values in the form and update the relevant row on the databse. BUT its not working...heres the code: UPDATE $tbl SET name='$name', lastname='$lastname', grade='$overall' WHERE id='$id' what is happening there!?? all the names correspond to the form correctly.... I am guessing something is worng with "UPDATE $tbl"?? Any help will be apprecieated....been driving me crazy!! thanks, Quote Link to comment https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/ Share on other sites More sharing options...
peranha Posted March 17, 2008 Share Posted March 17, 2008 What types of errors are you getting? the query looks correct to me. Quote Link to comment https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/#findComment-494090 Share on other sites More sharing options...
canox Posted March 17, 2008 Author Share Posted March 17, 2008 thats the thing... i am not getting any errors.... it returns successful. the database is not being updated. the permissions are correct.... Quote Link to comment https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/#findComment-494094 Share on other sites More sharing options...
canox Posted March 17, 2008 Author Share Posted March 17, 2008 Heres the full code: <?php $name=$_POST['name']; $lastname=$_POST['lastname']; $overall=$_POST['overall']; $tbl="term12008"; $host="localhost"; // Host name $username="innovati_grade1"; // Mysql username $password="merrigrade1"; // Mysql password $db_name="innovati_grade1"; // Database name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // update data in mysql database $sql="UPDATE $tbl SET name='$name', lastname='$lastname', grade='$overall' WHERE id='$id'"; $result=mysql_query($sql); // if successfully updated. if($result){ echo "Successful"; echo "<BR>"; echo "<a href='list_records.php'>View result</a>"; } else { echo "ERROR"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/#findComment-494096 Share on other sites More sharing options...
peranha Posted March 17, 2008 Share Posted March 17, 2008 $id is not being set in the code, is it set somewhere else, or am I just missing it Quote Link to comment https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/#findComment-494098 Share on other sites More sharing options...
canox Posted March 17, 2008 Author Share Posted March 17, 2008 BrILLIANT! jeeez you know sometimes the stupidest things are the ones you will never se or think about... thanks again, Quote Link to comment https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/#findComment-494100 Share on other sites More sharing options...
canox Posted March 17, 2008 Author Share Posted March 17, 2008 just a question... how do you enter in multiple values into an address bar? I want to retrieve data in the following php file by using the GET function... However i want to retrieve different values eg. <td align="center"><a href="updatestudent.php?id=<? echo $rows['id']; ?>,tbl=<? echo $rows['term']; ?>">update</a></td> in there i want to retrieve the ID value and the TERM value thanks thanks, Quote Link to comment https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/#findComment-494122 Share on other sites More sharing options...
peranha Posted March 17, 2008 Share Posted March 17, 2008 $id = $_GET['id']; $term = $_GET['tbl']; Quote Link to comment https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/#findComment-494123 Share on other sites More sharing options...
trq Posted March 17, 2008 Share Posted March 17, 2008 They need to be seperated by & That would be... <td align="center"><a href="updatestudent.php?id=<?php echo $rows['id']; ?>&tbl=<?php echo $rows['term']; ?>">update</a></td> Always best to use the full <?php ?> tags too. Quote Link to comment https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/#findComment-494124 Share on other sites More sharing options...
canox Posted March 17, 2008 Author Share Posted March 17, 2008 thanks! im loving this forum Quote Link to comment https://forums.phpfreaks.com/topic/96549-maybe-this-forum-will-help/#findComment-494127 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.