Ok! I just tweaked your code a little,
Update the code as suits you!
<?php
//Define database connection
$connection = mysql_connect('host', 'username', 'password');
//Select our database
if(!mysql_select_db('sample')) {
echo 'Could not connect to the database';
die();
}//if
$customers = mysql_query('select * from Customers', $connection);
while($profile = mysql_fetch_array($customers)) {
echo $profile['CustomerName'] . ', ' . $profile['ContactName'];
echo '<br/>';
}
mysql_close($connection);On Fri, Jul 26, 2013 at 3:09 PM, Andrew Nduati <nduatiandrew@gmail.com> wrote:
Thanks for the response. The problem is still the same. I've just tried getting rid of the second echo but all I get is a blank screen.And I've confirmed that the DB has records.On Fri, Jul 26, 2013 at 1:00 PM, Eugene Maritim <kiprotich.maritim@gmail.com> wrote:2. Changed mysql_select.db to mysql_select_db1. Swapped the order params of mysql_selectHey!Find edited code below:$password="";
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
//SQL Part
$host="localhost";
$username="root";mysql_select_db('sample') or exit("Database not found");
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
$result = mysql_query("SELECT * FROM profiles", $conn);
//Data from the query is stored in $result
while($row = mysql_fetch_array($result))
{
echo $row['CustomerName'] . " " . $row['ContactName'];
echo "<br>";
}
mysql_close($conn);
?>
</body>
</html>On Fri, Jul 26, 2013 at 2:46 PM, Andrew Nduati <nduatiandrew@gmail.com> wrote:
_______________________________________________Good Afternoon Skunks,Below is my PHP code that is meant to run an SQL Select query however it doesn't seem to be working. All I'm getting when I open it in the browser ("; } mysql_close($con); ?> ")Please assist.Kind regards.<html><head><title>PHP Test</title></head><body><?php//SQL Part$host="localhost";$username="root";$password="*****";$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());mysql_select.db('sample') or exit("Database not found");//Data from the query is stored in $result$result = mysql_query($conn,"SELECT * FROM Customers");while($row = mysql_fetch_array($result)){echo $row['CustomerName'] . " " . $row['ContactName'];echo "<br>";}mysql_close($conn);?></body></html>
skunkworks mailing list
skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke
_______________________________________________
skunkworks mailing list
skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke
_______________________________________________
skunkworks mailing list
skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke
_______________________________________________
skunkworks mailing list
skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke