Hello there please help me to solve the error i am facing off with this fetch image i have tried a lot but getting nothing to it so please help me to solve this
Database name= “job”
table name=“post”
Field name=“image”
Folder in which the image is stored =“Director-free/img”
Id=“20”
this is the description of my problem i am facing off And i want to fetch the image with reference of ID as image keeps on changing as i want to insert images for the users in my website so request you to make the code for this.
how about you make the code by yourself?
i Have tried it a lot but i am not getting it.
As a starting point, show us what you have tried already.
What specific errors are reported?
i Have inserted a select query i in but i am getting my page blank…
<?php
{
$connection = mysql_connect("localhost", "root", "");
$db = mysql_select_db("job", $connection);
$query = mysql_query("select file from post where id='20'", $connection);
$rows = mysql_num_rows($query);
if ($rows == 1) {
echo "image fetched ";
}
else
{
echo "not fetched";
}
}
?>
What query?
That is generally the result of an error, what does the error log say?
how do i fetch the same inserted from the folder Director-free/img.
First of all, mysql is gone! Use mysqli or PDO.
You appear to be mis-matching your column.
I have the old version of xampp installed which accept mysql
Is it old enough to not accept mysqli or pdo?
<?php
{
$connection = mysqli_connect("localhost", "root", "");
$db = mysqli_select_db("job", $connection);
$query = mysqli_query("select file from post where id='20'", $connection);
$rows = mysqli_num_rows($query);
if ($rows == 1) {
echo "image fetched ";
}
else
{
echo "not fetched";
}
}
?>
Here’s the code with mysqli…
This should be your best clue to the problem.
Inserting mysqli() gets error like this Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in
Is the id field a string or numeric datatype?
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.