some pointers on a php mysql connection
I am trying to start connecting php to my sql. I have a database created in phpmyadmin named 'snr' and that has a table named 'donate' which has four columns named 'user_ID', 'first_Name', 'last_Name' and donate_TOTAL.
When i run the following script in a browser I get the while loop showing and therefore nothing is returned via the echo statements. I want to show first_Name + last_Name.
<html>
<body>
<?php
$con = mysql_connect("localhost","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("snr", $con);
$result = mysql_query("SELECT * FROM donate WHERE user_ID > 0");
while($row = mysql_fetch_array($result))
{
echo $row['first_Name'] . " " . $row['last_Name'];
echo "<br />";
}
mysql_close($con);
?>
</body>
</html>
This is what is returned when i run it in a broswer.
0"); while($row = mysql_fetch_array($result)) { echo $row['first_Name'] . " " . $row['last_Name']; echo "
"; } mysql_close($con); ?>
Answer
Solution:
try this