Jump to content

[SOLVED] updating database


harkly

Recommended Posts

I am trying to update my database but it wont work - not getting any errors either.

 

I am pulling the info into a form on  one page and then passing it to another.

 

Page 1

mysql_select_db("artdb"); 

$search=$_GET["artid"];

//pulls info for Artist

$result = mysql_query("SELECT * FROM artist WHERE artid = '$search'");

            while ($r=mysql_fetch_array($result))
              {	
   $fullName=$r["fullName"];
   $artid=$r["artid"];

   //display the row

   echo "<tr><td><form method=\"get\" action='artist3.php'></td></tr>\n";
   echo "<input type=\"hidden\" name=\"artid\" value=\"$artid\"></td></tr>\n";
   echo "<tr><td><h3>Art Id</h3></td><td><input type=\"text\" name=\"artid\" value=\"$artid\"></td></tr>\n";
   echo "<tr><td><h3>Full Name</h3></td><td><input type=\"text\" name=\"fullName\" value=\"$fullName\"></td></tr>\n";
   echo "<tr><td><input type=\"submit\" name=\"button\" value=\"Update\"></td></tr>\n";
   echo "</form>\n";

}

 

passes to this page

 

mysql_select_db("artdb"); 

$search=$_GET["artid"];

   $fullName=$_GET["fullName"];
   $artid=$r["artid"];

echo "<table width=950 border=1 align=center>";
echo " <tr>";
   echo " <td width=200>";echo " </td>";
  echo " <td width=600>";

//pulls info for Artist

$result = mysql_query("UPDATE artist SET fullName ='$fullName' WHERE artid ='$artid'");

if(!$result){ echo " Unable to update your contacts";}else{echo "Your contacts updated successfuly";}

?>

 

I get the msg that it has been updated.

Link to comment
https://forums.phpfreaks.com/topic/137464-solved-updating-database/
Share on other sites

I changed the code but still no go..

 

Also looks like its not passing the info - checked with echo ".$fullName.";

 

mysql_select_db("artdb"); 

$search=$_GET["artid"];


//pulls info for Artist

$result = mysql_query("SELECT * FROM artist WHERE artid = '$search'");

  while ($r=mysql_fetch_array($result))
   {	

   $fullName=$r["fullName"];
   $artid=$r["artid"];


//display the row

   echo "<tr><td><form method=\"post\" action='artist3.php'></td></tr>\n";
   echo "<input type=\"hidden\" name=\"artid\" value=\"$artid\"></td></tr>\n";
   echo "<tr><td><h3>Art Id</h3></td><td><input type=\"text\" name=\"artid\" value=\"$artid\"></td></tr>\n";
   echo "<tr><td><h3>Full Name</h3></td><td><input type=\"text\" name=\"fullName\" value=\"$fullName\"></td></tr>\n";
   echo "<tr><td><input type=\"submit\" name=\"update\" value=\"Update\"></td></tr>\n";
   echo "</form>\n";


}

 

mysql_select_db("artdb"); 

$search=$_Post["update"];


   $fullName=$_Post["fullName"];
   $artid=$_Post["artid"];


//pulls info for Artist


$query = "UPDATE artist SET fullName = '$fullName' WHERE artid = '$artid' ";

$result = mysql_query($query) or die(mysql_error());


      if ($result)
      {
         echo "<h2>Information changed.</h2>\n";
      }
      else
      {
         echo "<h2>Sorry, I could not change the information.</h2>\n";
      }



?>

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.