Copy link to clipboard
Copied
Hi, I've recnetly begun learning PHP and seem to be progressing well. However, slightly stuck. I have an image URL in my database that I want to display but it is not. What am I doing wrong? Please find my code below. Really hope someone can point out what I'm doing wrong.
<?php
include 'connectionTest.php';
$prod = "SELECT titleImg FROM pages WHERE id=1";
?>
<img src="<?php echo $prod['titleImg'];?>" alt="The Salons" width="123" height="18" />
Look forward to some help ![]()
There's nothing to query your database. Also I can't tell what's in your connection include file and whether the databse is being connected. How does the source look in the browser after the page is rendered? What does the img src say when you view the source code from a browser? You need to see if the query is executed sucessfully and if it is then you need to determine the correct img path.
...<?php
include ("connectionTest.php");
$prod = "SELECT titleImg FROM pages WHERE id=1";$img_result=mysql_que
Copy link to clipboard
Copied
There's nothing to query your database. Also I can't tell what's in your connection include file and whether the databse is being connected. How does the source look in the browser after the page is rendered? What does the img src say when you view the source code from a browser? You need to see if the query is executed sucessfully and if it is then you need to determine the correct img path.
<?php
include ("connectionTest.php");
$prod = "SELECT titleImg FROM pages WHERE id=1";$img_result=mysql_query($prod);
$the_image=mysql_result($img_result,0,titleImg);
?><img src="<?php echo $the_image ?>" alt="The Salons" />
Copy link to clipboard
Copied
Hi there, your solution worked. Can't quite understand what each lines does but it's working now which is the main thing. Thanks so much for your help, greatly appreciated.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now