mysql - Error in my first php code using GET -


i writing first server side api, , code giving me errors...

here php code (i using method)

<?php   //check if there function if(function_exists($_get['function'])) {      //if equals loadall     if ($_get['function']=='loadall'){          //then call function , pass parameter needs         $_get['function']($_get['entity']);     }      //if found, call function value parameter    $_get['function']($_get['value']); }  /**  * method loads of object db  */ function loadall($entity){      //variables connecting database.     //these variable values come hosting account.     $hostname = "------";     $username = "-----";     $dbname = "-----";      //these variable values need changed before deploying     $password = "-----";      //connecting database     mysql_connect($hostname, $username, $password) or die ("unable      connect database! please try again later.");     mysql_select_db($dbname);      //fetching database table.     $query = "select * $entity";     $result = mysql_query($query);      $myjson=array();     //parse array     while($row = mysqli_fetch_array($result)){         $myjson[]=$row;     }      //close connection     mysqli_close($con);      //encode , send response     echo json_encode($myjson); } ?> 

my url is

http://someurl.com/api/index.php?function=loadall&entity=school 

my errors are:

warning: mysqli_fetch_array() expects parameter 1 mysqli_result, resource given in d:\hosting\somenumber\html\api\index.php on line 42  warning: mysqli_close() expects parameter 1 mysqli, null given in d:\hosting\somenumber\html\api\index.php on line 47 [] fatal error: function name must string in d:\hosting\somenumber\html\api\index.php on line 14 

i appreciate help

mysql , mysqli functions not interchangeable need use mysql or mysqli functions.

eg

//connecting database mysqli_connect($hostname, $username, $password) or die ("unable  connect database! please try again later.");//i changed mysqli_select_db($dbname);//i changed //fetching database table. $query = "select * $entity"; $result = mysqli_query($query);//i changed  $myjson=array(); //parse array while($row = mysqli_fetch_array($result)){       $myjson[]=$row; } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -