Jump to content

How Do I Pull Out Pix From Database


Panta
 Share

Recommended Posts

Please nice friends i have been trying to write a script that will upload pix to database and also pull it out to the browser, But i have been having problem with my code, Plz help me out. This is the code. Thanks

<?php$db = mysql_connect("localhost","Austin","password");mysql_select_db("school");$pname = $_REQUEST['pname'];$pdesc = $_REQUEST['pdesc'];$ftype = $_FILES['pfile']['type'];$fname = $_FILES['pfile']['name'];if ($_FILES['pfile']['size'] <= $_REQUEST['MAX_FILE_SIZE']){$fdata = fread(fopen($_FILES['pfile']['tmp_name'], "rb"),$_FILES['pfile']['size']);$fdata = base64_encode($fdata);$sql = "INSERT INTO pictures “;$sql .= “(poster_name,pdesc,ftype,fname,fdata) VALUES “;$sql .= “(\"${pname}\",\"${pdesc}\",”;$sql .= “\"${ftype}\",\"${fname}\",\"${fdata}\")";$query = mysql_query($sql) or die(mysql_error());echo "File Uploaded!";} elseecho "File Too Large";?>

Link to comment
Share on other sites

What problems are you having?
THE PROBLEM IS THAT THE SCRIPT IS NOT CORRECT. I DONT KNOW WHERE THE PROBLEM IS FROM, THE MORE I TRIED TO CORRCT IT THE MORE ERROR I SEE
Link to comment
Share on other sites

Specifically, what errors are you seeing? Are you getting error messages? Is the script doing something that it shouldn't be doing, or does it not do something that it should be doing? What happens when you use it?One thing I notice is that your SQL query contains invalid characters, specifically this character:“That might look like a quote, but it's not, it's some other character that things like MS Word and Wordpress like to use, but PHP doesn't see that as a quote. Make sure that your script only contains actual double quotes, not the stuff from Word or Wordpress. The semicolons look a little strange also, but that might just be the forum. Basically, don't copy and paste code from Wordpress, look at the code and just write it yourself.

Link to comment
Share on other sites

One thing I notice is that your SQL query contains invalid characters, specifically this character:“thanks so much. this has been the problem. is now working
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...