zzlawlzz Posted December 20, 2010 Share Posted December 20, 2010 I'm experimenting out premade codes and trying to make them some how work the way I want to. This is "my" image uploader. For the uploader is suppose to find the image AND the code stored in mysql, but it doesn't seem to find it. any problem? <?php $link = mysql_connect("localhost", "mcd", "whatanicepassword"); mysql_select_db("mcd", $link); if (!isset($_POST["code"])) { die ("Error: Not all fields complete"); } $limit_size=5120; $target = "skin/"; $target = $target . basename( $_FILES['uploaded']['name']); $ok=1; $filelol = $_FILES['uploaded']['name']; $file_size=$_FILES['uploaded']['size']; $filecheck = "skin/".$filelol; //This is our size condition if ($file_size >= $limit_size) { echo "Your file is too large.<br>"; $ok=0; } if (file_exists($filecheck)) { } else {echo $filelol." does not exist in the database. Please upload at the main site.<br>"; $ok=0;} // username and password sent from Form $uploaded=mysql_real_escape_string($_POST['uploaded']); $code=mysql_real_escape_string($_POST['code']); $checkquery = mysql_query("SELECT * FROM user_list WHERE uploaded = '$uploaded' AND code = '$code'") or die("Error : " . mysql_error()); $num_rows=mysql_num_rows($checkquery); if ($num_rows < 1 ) { echo 'File not found in MySQL<br><br><br>'; $ok=0; } else {echo 'YES!';} //This is our limit file type condition if (($_FILES["uploaded"]["type"] != "image/png")) { echo "You may only upload PNG files.<br>"; $ok=0; } if ($ok==0) { Echo "Sorry your file was not uploaded<br>"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ".$filelol." has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?> Link to comment https://forums.phpfreaks.com/topic/222214-mysql-select-not-working/ Share on other sites More sharing options...
BlueSkyIS Posted December 20, 2010 Share Posted December 20, 2010 what do you mean by "it doesn't seem to find it"? what happens? Any errors? have you tried echoing the SQL and running it via phpmyadmin or other? $sql = "SELECT * FROM user_list WHERE uploaded = '$uploaded' AND code = '$code'"; echo "sql: $sql <br />"; Link to comment https://forums.phpfreaks.com/topic/222214-mysql-select-not-working/#findComment-1149562 Share on other sites More sharing options...
zzlawlzz Posted December 20, 2010 Author Share Posted December 20, 2010 what do you mean by "it doesn't seem to find it"? what happens? Any errors? have you tried echoing the SQL and running it via phpmyadmin or other? $sql = "SELECT * FROM user_list WHERE uploaded = '$uploaded' AND code = '$code'"; echo "sql: $sql <br />"; Thanks! this help me find my problem. Link to comment https://forums.phpfreaks.com/topic/222214-mysql-select-not-working/#findComment-1149568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.