I literally just started looking into php, connecting to a remote database and returning data. I have been following a tutorial however when i apply the same code (as on the tutorial), i get
Server errorThe website encountered an error while retrieving http://localhost:8888/file.php. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this web page later.
<?php
// Database credentials
$host = "localhost";
$db = "json";
$uid = "json";
$pwd = "json1";
// Connect to the database server
$link = mysql_connect($host, $uid, $pwd) or die("Could not connect");
//select the json database
mysql_select_db($db) or die("Could not select database");
// Create an array to hold our results
$arr = array();
//Execute the query
$rs = mysql_query("SELECT id,userid,firstname,lastname,email FROM users");
// Add the rows to the array
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
?>
// Add the rows to the array
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
?>
{
on the while
line ; but never closing it.Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment