1 Replies - 219 Views - Last Post: 09 August 2012 - 10:21 PM Rate Topic: -----

#1 mikelash  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 94
  • Joined: 17-June 11

Working with images in php

Posted 09 August 2012 - 09:22 PM

I have been making a photo album on my website that pulls off pictures from a database and puts them on the screen. whats wrong is that every time i put a picture on the database that has a space in its name it ends right htere and hte picture becomes blank. so say the picture is called "turtles 10.jpg" it would just look for a picture called "turtles"

<?php
$query= stripslashes("select * from picture where username = '$stuff' order by count desc limit 0,500");  // query string stored in a variable
$rt=mysql_query($query);          // query executed 
echo mysql_error();                    // if any error is there that will be printed to the screen 
while($nt=mysql_fetch_array($rt)){
echo "<img width=200 height=200 src=" . $nt[picture] . "> <br> $nt[cap] <br>";     // picture class and mark will be printed with one line break

};
?>



Is This A Good Question/Topic? 0
  • +

Replies To: Working with images in php

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 2889
  • View blog
  • Posts: 7,535
  • Joined: 08-June 10

Re: Working with images in php

Posted 09 August 2012 - 10:21 PM

missing quotes for the src attribute.

your img tag would look like: <img width=200 height=200 src=turtles 10.jpg> in HTML where "10.jpg" would fall under the "unknown attribute" category.

a good reason to *always* quote attribute values.
Was This Post Helpful? 4
  • +
  • -

Page 1 of 1