Jump to content

englishcodemonkey

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

englishcodemonkey's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you guys, definately a newbie mistake! Thanks again , problem solved :D
  2. I cant get that code to work either . I thought that maybe the picture was too big as well, so on the file upload page i changed the max upload size and still no luck, do you no what error=> 2 stands for? Is it a specific error code? I cant see it in the php manual either! Sorry
  3. Hi guys, I am trying to upload a file to my hosting account on godaddy, and it works some of the time, and the rest of the time it displays the error below: I'm using print_r($_FILES) to display the error, what does error=>2 mean? ( [userfile] => Array ( [name] => absolutetreas.gif [type] => [tmp_name] => [error] => 2 [size] => 0 ) ) This is the code i'm using to upload the pic: $uploaddir = '../images/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); echo '<pre>'; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; echo 'Here is some more debugging info:'; print_r($_FILES); print "</pre>"; } Thanks so much!
  4. Hi guys, So i'm trying to display an image with the code $picname = $row["fileContents"]; } echo "<img src = '$picname' >"; but if there are no results in internet explorer it shows a red X since it cant find the image, i've tried using "if(mysqli_num_rows($r)==0)" but this doesnt work. i'm using mysqli and so wondered if anyone had any other ideas.the query is shown below this: $q = "SELECT description from hosta where hosta_name='$hosta1'"; $r = mysqli_query ($dbc, $q); if ($r) { echo ' <table align="center" cellspacing="3" cellpadding="3" width="90%"> <tr> <td align="left"><b>Description</b></td> </tr>'; while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) { echo ' <tr> <td align="justify">' .$row['description'] . '</td> </tr>'; } } echo '</table>'; $dbc = mysqli_connect ('****', '****', '****', '****'); $sqlimage = "SELECT * from image, hosta WHERE id=hosta_id and hosta_name = '$hosta'"; $sql_imgresult = mysqli_query($dbc,$sqlimage); while ( $row = mysqli_fetch_array ($sql_imgresult) ) { $picname = $row["fileContents"]; } echo "<img src = '$picname' >"; mysqli_close($dbc); ?>
  5. ok so i'm trying another way still with no luck, i have the "<img src="index.php" />" on one page and then the code for index.php is below: <?php $img = "P7180104.JPG"; $q = "SELECT fileContents from image where id='1'"; $r = @mysqli_query ($dbc, $q); $imagepath="$r"; $image=imagecreatefromjpeg($imagepath); header('Content-Type: image/gif'); imagejpeg($image); ?> if i just type the filepath after "$imagepath" then it will display the image, but it will not find the file path from the database. i'm thinking maybe i have performed the query incorrectly? is "where id='1'" correct? Thanks
  6. Ok i have a database called "image" with which i am storing images in blob format.i am currently trying to display the images that are in the database in this table. this is my current code for index.php: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Browse Upload Files</title> </head> <body bgcolor="white"> <?php include 'db.inc'; $query = "SELECT id, shortName, mimeName FROM image"; /*if (!($connection = @ mysql_pconnect($hostName, $username, $password))) showerror(); if (!mysql_select_db("files", $connection)) showerror(); if (!($result = @ mysql_query ($query, $connection))) showerror();*/ ?> <h1>Image database</h1> <h3>Click <a href="insert.php">here</a> to upload an image.</h3> <?php //require 'disclaimer'; if ($row = @ mysqli_fetch_array($result)) { ?> <table> <col span="1" align="right"> <tr> <th>Short description</th> <th>File type</th> <th>Image</th> </tr> <?php do { ?> <tr> <td><?php echo "{$row["shortName"]}";?></td> <td><?php echo "{$row["mimeName"]}";?></td> <td><?php echo "<img src=\"view.php?file={$row["id"]}\">";?></td> </tr> <?php } while ($row = @ mysqli_fetch_array($result)); ?> </table> <?php } // if mysql_fetch_array() else echo "<h3>There are no images to display</h3>\n"; ?> </body> </html> db.inc: <?php // These are the DBMS credentials $hostName = "****"; $username = "****"; $password = "****"; // Show an error and stop the script function showerror() { if (mysqli_error()) die("Error " . mysqli_errno() . " : " . mysqli_error()); else die("Could not connect to the DBMS"); } // Secure the user data by escaping characters // and shortening the input string function clean($input, $maxlength) { $input = substr($input, 0, $maxlength); $input = EscapeShellCmd($input); return ($input); } ?> and view.php: <?php include 'db.inc'; $file = clean($file, 4); if (empty($file)) exit; if (!($connection = @ mysqli_pconnect($hostName, $username, $password))) showerror(); if (!mysqli_select_db("files", $connection)) showerror(); $query = "SELECT mimeType, fileContents FROM image WHERE id = $file"; if (!($result = @ mysqli_query ($query,$connection))) showerror(); $data = @ mysqli_fetch_array($result); if (!empty($data["fileContents"])) { // Output the MIME header header("Content-Type: {$data["mimeType"]}"); // Output the image echo $data["fileContents"]; } ?> when i upload this to my host and view the index.php file it says there are no images to display, but i have images there! Thanks and sorry if this is a stupid mistake, just need another pair of eyes to take a look! thanks!
  7. So i am lost after reading a lot about variables i want to know whether there is a way to assign a value to my variable from a mysql query. my code is : ?php require_once('conn.php'); $pic = $_REQUEST['image']; $q = "SELECT image FROM hosta, images WHERE hosta_name = $pic, imgid = hosta_id"; $r = @mysqli_query ($dbc, $q); if ($r) { while($row=mysql_fetch_array($result)){ echo "'image'$img=$row['image']"; } } $path = "http://********.com/$img"; $imagepath=$path; $image=imagecreatefromjpeg($imagepath); header('Content-Type: image/jpeg'); imagejpeg($image); ?> The variable $pic is coming from a form, but the variable $img i am hoping will be filled from my query to the database? I have only ever used queries to fill dropdown boxes or tables, so I am totally lost on how to make this a dynamic variable so to say. Any ideas?
  8. I'm not sure if this is possible, or whether there is an easier way to do this. I have a drop down box where you select an option and this value is posted to a php script where it is used as a variable to retrieve data from the mysql database. This works fine and I can retreive information about each selected option which is targeted to a frame on my catalog page. The question is can i also use this form to post the variable to another frame to show my image?? I can get an image to show from a different drop down box but ideally i need the picture and the information to displayed at just one selection. Any ideas?
  9. i noticed that to when i viewed the source. Where could this be coming from?? I'm so confused at this point! Also when i viewed the source it displays all the binary...ahhhh!
  10. Could someone have a look at this and explain to me why i can only see the binary, I have tried having a html page with <img src> pointing to my php file. And then having no html in the php file at all. I still just see binary. I had an error for a while with not being able to change the header but i have solved that problem by removing the html that was before it. Any ideas please???
  11. This is the exact code...what instructions am i not following??? <?php header("content-type:image/jpeg"); require_once('conn.php'); $q = "SELECT image from images where imgid='2'"; $r = @mysqli_query ($dbc, $q); $row = mysqli_fetch_assoc($r); $news = imagecreatefromstring($row['image']); $final = imagejpeg($news); ?>
  12. I still just see binary www.wadeandgattonnurseries.com/showimage2.php
  13. I'm just trying different things because i don't understand why i can only see binary!! What do you suggest to get this to work?? Thanks
  14. Ok i have now edited my code again: <?php header("content-type:image/jpeg"); require_once('conn.php'); ?> <html> <head> <title>Untitled Document</title> </head> <body> <?php $q = "SELECT image from images where imgid='2'"; $r = @mysqli_query ($dbc, $q); $data = mysqli_fetch_assoc($r); $data = base64_decode($data); $im = imagecreatefromstring($data); if ($im !== false) { header('Content-Type: image/jpg'); imagejpg($im); } else { echo 'An error occured.'; } ?> The error i am getting is below: Warning: imagecreatefromstring() [function.imagecreatefromstring]: Empty string or invalid image in /home/content/j/e/s/jesspomfret/html/showimage2.php on line 18 Line 18 is $im = imagecreatefromstring($data); I still don't see my image?!? Any ideas?
×
×
  • 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.