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... Quote Link to comment 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}'"); Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.