遇到错误,说json_encode not supported by web server
。
这是代码:
<?php
require_once('db_login.php');
$con=mysql_connect($db_host,$db_user,$db_password);
if(!$con)
die("Could not connect to database");
else echo "Connected to the server" ;
if(mysql_select_db($db_database,$con))
echo"Connected to database";
else
{echo "Unable to select database",mysql_error();}
$user=$_POST['login1'];
$passwd=$_POST['login2'];
//$sql=mysql_query("INSERT INTO temp (user,password)VALUES('user','$passwd')");
$sql=mysql_query("select * from appusers where username='$user'");
if (!$sql) die ("Database access failed: " . mysql_error());
else
{
echo("Successful");
print(json_encode($sql));
}
?>
该代码用于将用户名和密码传递给 android 应用程序。请帮忙。