mcirl2 Posted February 26, 2008 Share Posted February 26, 2008 Hi, I have a simple php script which will retrieve images from the table based on the query. The problem is that when I hard code a value to the $id variable that I use in the select statement, the image is dislayed no problem. However as soon as I use the $_GET['id'] variable in the query it wont work. It prints out other text values for the row, but not the iimage. Here's my code: <?php // Connect to database $errmsg = ""; if (! @mysql_connect("localhost","root","******")) { $errmsg = "Cannot connect to database"; } @mysql_select_db("*****"); $id = $_GET['id']; //$id = 31; //when I uncomment the above variable the query will pull out all the values where AdvID = 31 //but when I use the Get ID .. it wont work. The value of $_GET['id'] is 31 also. $slqQ = @mysql_query("select * from advpics where AdvID = $id"); if ($row = @mysql_fetch_assoc($slqQ)) { $title = htmlspecialchars($row[title]); $bytes = $row[imgdata]; $desc = $row ['AdvID']; } //If this is the image request, send out the image if ($_REQUEST[gim] == 1) { header("Content-type: image/jpeg"); print $bytes; exit (); } ?> <html><head> <title>Upload an image to a database</title> <body bgcolor=white><h2 align="center">Here's the latest picture</h2> <font color=red><?= $errmsg ?></font> <center><img src=?gim=1 width=144><br> <p align="center"><?= $title ?></p> <p><?= $desc; ?></p> </center> </body> </html> I would really appreciate some help, cant figure it out at all. Thanks, Mike Quote Link to comment Share on other sites More sharing options...
amites Posted February 26, 2008 Share Posted February 26, 2008 my suggestion: get those images out of the database and place them on the server somewhere, then put pointers to the images in your database, make sense? Quote Link to comment Share on other sites More sharing options...
mcirl2 Posted February 28, 2008 Author Share Posted February 28, 2008 hey, the problem is that I need to store the images in the database because users can create profiles and so they would have to create a seperate directory every time they create a profile so its easier to store int he database. I wish I didnt have too, its a nightmare!! Any other ideas - anyone?? Quote Link to comment Share on other sites More sharing options...
dave420 Posted February 28, 2008 Share Posted February 28, 2008 I'd recommend you store them in the filesystem - that's what it's there for Make your script create the necessary directories as needed, and do it that way. 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.