Unstoppable Domains โ€” AI Assistant

Updating with PHP and MYSQl Just wont work. Any Advice?

Spaceship Spaceship
Watch

brianwiz

Established Member
Impact
1
Code one from Update page:

<form action="updated2.php">
<input type="hidden" name="ud_id" value="<? echo "$id"; ?>">
Customer ID: <input type="text" name="ud_Customerid" value="<? echo "$CustomerID"?>"><br>
First Name: <input type="text" name="ud_Fname" value="<? echo "$fname"?>"><br>
Last Name: <input type="text" name="ud_lname" value="<? echo "$lname"?>"><br>
Email: <input type="text" name="ud_Email" value="<? echo "$Email"?>"><br>
Apprasial Recieved: <input type="text" name="ud_Recieved" value="<? echo "$Recieved"?>"><br>
Apprasial Done: <input type="text" name="ud_Done" value="<? echo "$Done"?>"><br>
<input type="Submit" value="Update">
</form>

<?
mysql_connect(localhost,"Blank","Blank");
@mysql_select_db("Blank") or die( "Unable to select database");
$query="SELECT * FROM users WHERE id='$CustomerId'";
$result=mysql_query($query);
mysql_close();

$i=0;
while ($i < $num) {
$First=mysql_result($result,$i,"fname");
$Last=mysql_result($result,$i,"lname");
$Email=mysql_result($result,$i,"Email");
$Recieved=mysql_result($result,$i,"Recieved");
$Done=mysql_result($result,$i,"Done");


?>


<?
++$i;
}
?>

Code two from Updated2 Page

<?php

$ud_id=$_POST['ud_CustomerId'];
$ud_first=$_POST['ud_fname'];
$ud_last=$_POST['ud_lname'];
$ud_phone=$_POST['ud_Email'];
$ud_mobile=$_POST['ud_Recieved'];
$ud_email=$_POST['ud_Done'];

$username="blank";
$password="blank";
$database="blank";

mysql_connect(localhost,$username,$password);


$query="UPDATE users SET first='$ud_fname, last='$ud_lname', phone='$ud_Email', mobile='$ud_Recieved', fax='$ud_Done', WHERE id='$ud_CustomerId'";
mysql_query($query);
echo "Record Updated";
mysql_close();

?>

This code will say it is updated by when i go look into mysql database its not any different.

any help would be appreciated

The database values are:
CustomerID
fname
lname
Email
Recieved
Done

I have a register and search page that work fine. Just trying to get updated and hopefully a delete page.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
$query="UPDATE users SET first='$ud_fname, last='$ud_lname', phone='$ud_Email', mobile='$ud_Recieved', fax='$ud_Done', WHERE id='$ud_CustomerId'";
mysql_query($query);
echo "Record Updated";
mysql_close();


first='$ud_fname, < -- there is a ' missing on the end there.
 
0
•••
I updated that and that didnt help one way or another. Thanks for pointing that out i appreciate that

Im thinking my problems lies here

Update1.php

$i=0;
while ($i < $num) {
$First=mysql_result($result,$i,"fname");
$Last=mysql_result($result,$i,"lname");
$Email=mysql_result($result,$i,"Email");
$Recieved=mysql_result($result,$i,"Recieved");
$Done=mysql_result($result,$i,"Done");


updated2.php

$ud_id=$_POST['ud_CustomerId'];
$ud_first=$_POST['ud_fname'];
$ud_last=$_POST['ud_lname'];
$ud_phone=$_POST['ud_Email'];
$ud_mobile=$_POST['ud_Recieved'];
$ud_email=$_POST['ud_Done'];
 
0
•••
brianwiz said:
I updated that and that didnt help one way or another. Thanks for pointing that out i appreciate that

Im thinking my problems lies here

Update1.php

$i=0;
while ($i < $num) {
$First=mysql_result($result,$i,"fname");
$Last=mysql_result($result,$i,"lname");
$Email=mysql_result($result,$i,"Email");
$Recieved=mysql_result($result,$i,"Recieved");
$Done=mysql_result($result,$i,"Done");


updated2.php

$ud_id=$_POST['ud_CustomerId'];
$ud_first=$_POST['ud_fname'];
$ud_last=$_POST['ud_lname'];
$ud_phone=$_POST['ud_Email'];
$ud_mobile=$_POST['ud_Recieved'];
$ud_email=$_POST['ud_Done'];


PHP:
mysql_connect(localhost,"Blank","Blank");
@mysql_select_db("Blank") or die( "Unable to select database");
$query="SELECT * FROM users WHERE id='$CustomerId'";
$result=mysql_query($query);

$data = mysql_fetch_assoc($result);

print $data['fname'];
print $data['lname'];

give that a buzz =)

<form action="updated2.php">
you need to do
<form action="updated2.php" method="post"> otherwise it'll "get" the form (ie $_GET['']
 
0
•••
Updated the still says Recored Update and nothing on the database.
 
0
•••
did you select the database name in updated2.php? I couldn't tell if you were just providing snippets of code or if you pasted the entire code.
 
0
•••
That is the entire code minus the database name/username and password.

On updated 2 i had this

$query="UPDATE users

which i believed selected the databse.

Do you want me to post my updated code with the changes i made from previous suggestion?

I have also looked at my register/registertest pages and followed that example in terms of variables naming for database.
 
0
•••
What you need to add is something like what you have on update1.php

Code:
@mysql_select_db("Blank") or die( "Unable to select database");
so that the script knows what database to select.

Code:
$query="UPDATE users
simply says which table to query.

Hope this helps.
 
0
•••
Thanks will work on that portion. I appreciate the feedback and help so far.
 
0
•••
no problem. If you continue to experience problems feel free to PM as I might not be viewing this thread. I'll be glad to help you out. Good luck!
 
0
•••
I have gotten this to work Thanks all for the help
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back