Jump to content

[SOLVED] Please help --> Getting an image path from mysql


chrisis11

Recommended Posts

Hi, I know I am knew, but at the moment I feel really stupid, beacuse I cannot make this script work.

Before I ask what/ how to do and waht i am doing wrong, this is 'growing jalapeno peppers'. Just so no-one gets the erm, wrong idea!

I know for a fact that this works, because it serves the data:

<?php
// Make a MySQL Connection
mysql_connect("localhost", "*myusername*", "*mypassword*") or die(mysql_error());
mysql_select_db("chris_grow") or die(mysql_error());

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM grow") 
or die(mysql_error());  
echo "<table border='1' width='100%'>";
echo "<tr> <th>ID Number</th> <th>Day Number</th> <th>Stage Of Growth</th> <th>Current Height</th> <th>Hours of Light/Dark</th> <th>Description</th> <th>Photo</th></tr>";
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>"; 
echo $row['ID'];
echo "</td><td>"; 
echo $row['day'];
echo "</td><td>";
echo $row['stage'];
echo "</td><td>";
echo $row['height'];
echo "</td><td>";
echo $row['hours'];
echo "</td><td>";
echo $row['description'];
echo "</td></tr>";
} 

echo "</table>";
?>

Basically my MySQL table looks like this

ID day stage height hours description photo

1 1 Germination 0.0mm 11/13 All is well images/1.jpg

What I would like to do, is bring photo 'images/1.jpg' into the last column, and I have tried everything including but not limited to

echo "<img src='{$row_grow['photo']}' />"

(In a cell in the table)

So I am really at a loose end, it must be possible.

Help :(

Chris

Yeah, neither work, and when I hit properties of where the images is meant to be I get

as the source of the picture - no 1.jpg or even /images......?

And when its like this:

echo "<a href='http://google.com'><img src='$row['photo']' /></a>";

All I get is an error for that line

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/chris/public_html/grow/index.php on line 27

Chris

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.