adzie Posted May 26, 2007 Share Posted May 26, 2007 I recently changed from linux/unix server to windows and discovered my scripts didnt work. I have got an update script that puts the information into a form, which is now working with this code <? $vid=$_GET['VID']; include("db.php"); $query="SELECT * FROM members WHERE vid='$vid'"; $result=mysql_query($query); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $vid=mysql_result($result,$i,"vid"); $name=mysql_result($result,$i,"name"); $password=mysql_result($result,$i,"password"); ?> <b><font color="#000080" face="Verdana">Database Update Form</font></b> <form action="updated.php"> <p>VID: <input type="text" name="VID" value="<? echo "$vid" ?>"?><br> Name: <input type="text" name="NAME" value="<? echo "$name" ?>"?><br> PASSWORD: <input type="text" name="PASSWORD" value="<? echo "$password" ?>"?><br> <input type="Submit" value="Update"> </p> </form> <? ++$i; } mysql_close(); ?> the script that updates updated.php is below, I can view the data and edit it but the change doesnt save to the db, any suggestions? <? $username="data"; $password="data"; $database="data"; mysql_connect(localhost,$username,$password); $query="UPDATE members SET vid='$vid', name='$name', password='$password' WHERE vid='$vid'"; @mysql_select_db($database) or die( "Unable to select database"); mysql_query($query); echo "Record Updated"; echo "<center><font face='Verdana' size='2' ><br>Management Console <br><br>Click Amend to edit members details<br><br><a href=index.php>Return to user list</a><br><a href=console.php>Return to management console</a><br><br><br></center></font>"; mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/53058-update-script-not-updating/ Share on other sites More sharing options...
AndyB Posted May 26, 2007 Share Posted May 26, 2007 $query="UPDATE members SET vid='$vid', name='$name', password='$password' WHERE vid='$vid'"; Nowhere in your script are the values of those variables obtained. Perhaps you're assuming they exist globally but your server has register_globals set to OFF (the secure and current default setting). If those values come from a form with the POST method, you'll need to abstract them from the $_POST array. Link to comment https://forums.phpfreaks.com/topic/53058-update-script-not-updating/#findComment-262172 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.