php, sql storing and displaying image strings

Hi, hope someone can help with my problem.
Ive followed a youtube tutorial of how to display data from my sql database using php and it works fine for text, however now i wish to display an image stored in a folder using a image path, but im stumped of how to do this, in mysql i have a database called days, with a table called adrenaline and field called image_path set as varchar (250) and have set the data as: C:\xampp\htdocs\img\bg.png

The code im using is:

[php] <?php
//connect to the server
$connect = mysql_connect(“myip”,“root”,“mypassword”);

//connect to the database
mysql_select_db(“days”);

//query the database
$query = mysql_query("SELECT * FROM adrenaline WHERE id = ‘1’ ");

//ferch the results / convert results into an array

	WHILE($rows = mysql_fetch_array($query)):
	
		$image_path = $rows['image_path'];
		
	echo "$image_path";
	endwhile;

?>[/php]

but this just seems to display the image path as text and not display the images, im not sure if the code that was working for displaying text from my database is not designed for displaying images?

Many thanks.

[php]echo ‘’;[/php]

You will only need to include the image path as img/bg.png as long as the page you are viewing is in root of localhost

Sponsor our Newsletter | Privacy Policy | Terms of Service