Jump to content

Recommended Posts

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

$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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.