im trying to query the databse and all i want to do is to query the database then when it gets the result i do not want to echo it, i want to use it for an if statement so i would query it then with the result put if result equals 0 do this else....ect.
heres the whole script
<? //subitimage.php
session_start(); //starts session
include ( "config.php" ); // includes the config file
if ($logged["username"]) { //checks user is logged in
if($_POST["submit"]){
$result = mysql_query("SELECT * FROM `default_images` WHERE username` = '$logged[username]'");
while($row = mysql_fetch_array($result))
if($row[image]=0)
{
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
$ext = findexts ($_FILES['image']['name']);
$ran = rand () ;
$ran2 = $ran.".";
$target = "default_images/"; //destination
$target = $target . $ran2.$ext;
if(move_uploaded_file($_FILES['image']['... $target))
{
$image = $target;
$username = strip_tags(htmlspecialchars($logged["use... //username
$url = htmlspecialchars($_POST["url"]); // orignal url
$do = mysql_query( "INSERT INTO `default_images` ( `username` , `url` , `image` ) VALUES ( '$username' , '$url' , '$image' ) ");
echo "Your image has been submitted"; // echo this message
}
}
else
{
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
$ext = findexts ($_FILES['image']['name']);
$ran = rand () ;
$ran2 = $ran.".";
$target = "images/"; //destination
$target = $target . $ran2.$ext;
if(move_uploaded_file($_FILES['image']['... $target))
{
$image = $target;
$username = strip_tags(htmlspecialchars($logged["use... //username
$url = htmlspecialchars($_POST["url"]); // orignal url
$do = mysql_query( "INSERT INTO `image_requests` ( `username` , `url` , `image` ) VALUES ( '$username' , '$url' , '$image' ) ");
echo "Your image has been submitted"; // echo this message
}
}
}
}
echo "<form enctype='multipart/form-data' method='POST'>
<table cellspacing='0'>
<tr>
<td colspan='2'>Image</td>
<td colspan='2'><input type='file' size='30' name='image'></td>
</tr>
<tr>
<td colspan='2'>Original url</td>
<td colspan='2'>http:// <input type='text' size='30' name='url'></td>
<td colspan='4' align='center'><input type='submit' name='submit' value='Upload'></td>
</tr>
</table>
</form>"; //echos form
?>
Tags: