MDanz Posted August 28, 2009 Share Posted August 28, 2009 session_start(); $username1 = $_SESSION['username']; // set them to your login information. $username = "Master"; $password = "password"; $host = "localhost"; $database = "db"; // Make the connect to MySQL or die // and display an error. $link = mysql_connect($host, $username, $password); if (!$link) { die('Could not connect: ' . mysql_error()); } // Select your database $image = mysql_real_escape_string($_POST['image']); $query= mysql_query("UPDATE Reply SET image=$image WHERE username=$username1"); if($query) { print "<br><font color=white>Your avatar has been set. <a href='member.php'>Return to Upload Page</a></font>"; } else { print "No image selected/uploaded"; } Where am i going wrong? its not uploading to mysql. I want it to update all rows where username = $username1, with $image for the image field. Its not working so mine obviously not right... Link to comment https://forums.phpfreaks.com/topic/172304-solved-update-in-database/ Share on other sites More sharing options...
Cetanu Posted August 28, 2009 Share Posted August 28, 2009 mysql_query("UPDATE Reply SET image='{$image}' WHERE username='{$username1}'"); Link to comment https://forums.phpfreaks.com/topic/172304-solved-update-in-database/#findComment-908448 Share on other sites More sharing options...
ReKoNiZe Posted August 28, 2009 Share Posted August 28, 2009 You have "// Select your database" but you never select a database. You need a : mysql_select_db($database) or die("Unable to connect to database"); You need to have that before you run your query Link to comment https://forums.phpfreaks.com/topic/172304-solved-update-in-database/#findComment-908450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.