Jump to content

Mysql Select not working


zzlawlzz

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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