I have a function that outputs several credits:
<?php function selectCredits() { include 'sqlvars.php'; $con = mysql_connect("localhost","bbbb","bbbb"); if (!$con){ die('Could not connect: ' . mysql_error()); } mysql_select_db("bbbb", $con); $result = mysql_query($selectCredits); while($row = mysql_fetch_array($result)){ echo $row['credits']; } } ?>
When I call it from a php file using:
<?php include 'sql.php'; selectCredits(); ?>
I can see the result, but when I'm inside the HTML document, I canβt get the result using this code:
<center><b>Your credits: </b></center> <?php include 'sql.php'; selectCredits(); ?>
The solution is always: Your credits: no query result.
Of course, I miss something very small. I am not a php guy, but I want to find out after losing an hour without success.
source share