I am just having an error in my output through my php file. I believe it is an easy fix. While it should be displaying data it is displaying this.
[{"first_name":"first_name","mobile_phone":"mobile_phone"},`
and here is my php file. Really hope this is a simple fix. Thanks
<?php
function connect() {
// Connecting to mysql database
$con = mysql_connect(private);
// Selecing database
$db = mysql_select_db("intraweb_db") or die(mysql_error()) or die(mysql_error());
// returing connection cursor
return $con;
}
//end of connect to db
connect();
$sql=mysql_query("SELECT 'first_name', 'mobile_phone' FROM `admin_contacts`");
$output = array();
while($r = mysql_fetch_assoc($sql)){
$output[]=$r;
}
echo json_encode($output);
?>
Awesome ;) thank you guys. got it working
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the pink box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.mysql_*is deprecated, consider usingmysqliorPDO. Can you please useprint_r($output)before thejson_encodefunction and update us - what's the output.mysql_select_db()dies it can die again.