chrisis11 Posted November 16, 2009 Share Posted November 16, 2009 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 Link to comment https://forums.phpfreaks.com/topic/181794-solved-please-help-getting-an-image-path-from-mysql/ Share on other sites More sharing options...
mrMarcus Posted November 16, 2009 Share Posted November 16, 2009 you know you have $row_grow['photo'] instead of $row['photo'], right? Link to comment https://forums.phpfreaks.com/topic/181794-solved-please-help-getting-an-image-path-from-mysql/#findComment-958766 Share on other sites More sharing options...
chrisis11 Posted November 16, 2009 Author Share Posted November 16, 2009 Yeah, neither work, and when I hit properties of where the images is meant to be I get http://****.me/grow/Array 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 Link to comment https://forums.phpfreaks.com/topic/181794-solved-please-help-getting-an-image-path-from-mysql/#findComment-958772 Share on other sites More sharing options...
premiso Posted November 16, 2009 Share Posted November 16, 2009 echo "<a href='http://google.com'><img src='$row['photo']' /></a>"; Try this instead: echo "<a href='http://google.com'><img src='{$row['photo']}' /></a>"; See if that improves it all Link to comment https://forums.phpfreaks.com/topic/181794-solved-please-help-getting-an-image-path-from-mysql/#findComment-958773 Share on other sites More sharing options...
mrMarcus Posted November 16, 2009 Share Posted November 16, 2009 k, try this: echo '<img src="'.$row['photo'].'" />'; note: you must use $row as you have not defined $row_grow, therefore, it will not work as expected. Link to comment https://forums.phpfreaks.com/topic/181794-solved-please-help-getting-an-image-path-from-mysql/#findComment-958775 Share on other sites More sharing options...
chrisis11 Posted November 16, 2009 Author Share Posted November 16, 2009 Woo, thankyou, though I swear I had tried that. Ahwell you lot are so much help. I am only using SQL for this project to try and familiarize myself with the commands and stuff. Thankyou, Will mark as solved, Chris Link to comment https://forums.phpfreaks.com/topic/181794-solved-please-help-getting-an-image-path-from-mysql/#findComment-958779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.