MYSQL / PHP problem

  • Pbpixels
  • Novice
  • Novice
  • User avatar
  • Posts: 17

Post 3+ Months Ago

PHP Code: [ Select ]
$data = mysql_query("SELECT photo FROM pbphoto WHERE id = $id")
 or die(mysql_error());
 $photo = mysql_fetch_array($data);
echo "$photo";
 
  1. $data = mysql_query("SELECT photo FROM pbphoto WHERE id = $id")
  2.  or die(mysql_error());
  3.  $photo = mysql_fetch_array($data);
  4. echo "$photo";
  5.  


Turns out to be: Array
I need "$photo" to get me the name of the photo in the photo column with the id of $id.

but instead of giving me a name like: "smileyman.png" it just give me "Array". For not long ago, it gave me resource #7 or something as well lol.

Does anybody know a solution to this? Thanks :)
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • jammer2552
  • Graduate
  • Graduate
  • User avatar
  • Posts: 139

Post 3+ Months Ago

You don't do any processing after '$photo = mysql_fetch_array($data);', so $photo contains the row in array form. Also, when using the echo statement, and you're only echoing one variable, you don't need quotation marks - that invokes PHP parsing which is unnecessary.

PHP Code: [ Select ]
$data = mysql_query("SELECT `photo` FROM `pbphoto` WHERE `id` = {$id}") or die(mysql_error());
$photo = mysql_fetch_array($data);
$photo = $photo['photo'];
 
echo $photo;
 
  1. $data = mysql_query("SELECT `photo` FROM `pbphoto` WHERE `id` = {$id}") or die(mysql_error());
  2. $photo = mysql_fetch_array($data);
  3. $photo = $photo['photo'];
  4.  
  5. echo $photo;
  6.  
  • Pbpixels
  • Novice
  • Novice
  • User avatar
  • Posts: 17

Post 3+ Months Ago

Thanks a lot :) I fixed the problem (y)

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 62 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.