Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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