php - Create a hidden image when I check if I have an entry in my database
Get the solution ↓↓↓Solution:
Two things. First you're not doing a comparison here -
if(mysql_num_rows($query)=0) // you need != (not equal) or > (greater than) or == (equal to)
Secondly, you're not echoing your HTML markup. That should cause errors. You should either close the PHP tags or echo the markup so you get correct output. For instance:
echo '<a href="cv/addcv.php"><img src="images/addcv.png" style="display: none;"> </a>';
You should add error reporting to the top of your file(s) right after your opening<?php
tagerror_reporting(E_ALL); ini_set('display_errors', 1);
so that you see all of the errors.
Please, stop using .
They are no longer maintained and are officially deprecated. Learn about prepared statements instead, and use PDO. You're inviting SQL injection!
Answer
Solution:
It doesn't work because you didn't add the PHP end tag before your HTML. Try this:
<?php
if($query = mysql_query("SELECT name,email,city,phone FROM personal_information WHERE id>'$id' AND username='$username'"))
{
if(mysql_num_rows($query)==0)
{
?>
<a href="cv/addcv.php"><img src="images/addcv.png" style="display: none;"> </a>
<?php
}
else
{
?>
<a href="cv/addcv.php"><img src="images/addcv.png" style="width:120px;height:120px"> </a>
<?php
}
}
?>
Answer
Solution:
Change
if(mysql_num_rows($query)=0)
To
if(mysql_num_rows($query)==0)
Also: the mysql functions are deprecated. Please use PDO instead. If that is not an option for some reason, you can also use the mysqli functions, but PDO is recommended nowadays.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: unable to determine current zabbix database version: the table "dbversion" was not found.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.