-9

このトピックはすでに数回投稿されていますが、SO でここに投稿されたソリューションは役に立たないようです。セミコロン、スペース、およびクエリを確認しましたが、subjaccess.php を呼び出すたびに、php で解析エラーが引き続き発生します。

Parse error: syntax error, unexpected T_STRING in /home/a8367888/public_html/subjaccessrequest.php on line 14

ここに私のPHPコードがあります:

<?php
$mysql_hostname = "localhost";
$mysql_database = "database";
$mysql_user = "username";
$mysql_password = "password";

//$pass = $_POST['email'];
$pass = "blahblach@gmail.com";

$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
or die("Opps something went wrong");
mysql_select_db($mysql_database, $bd) or die("Oops something went wrong");

$query =  "SELECT (a.acode) as "access_id", (s.s_first_name) as "fname",      (s.s_middle_initial) as "mname", (s.s_last_name) as "lname", (a.s_email) as "email", (a.req_subj) as "subjcode"
FROM access a, student s
WHERE a.s_email = s.s_email
AND a.t_email = '$pass' 
AND a.access_status = "pending";

$result = mysql_query($query) or die('MySql Error' . mysql_error());

while ($row = mysql_fetch_array($result))
{
 $res[]=array('aid'=> $row['access_id'],'fname'=> $row['fname'],'mname'=> $row['mname'], 'lname'=> $row['lname'], 'email'=> $row['email'], 'subj'=> $row['subjcode']);
}

echo '$res';

$response['request'] = $res;
print(json_encode($response));
?>

あなたの応答を期待しています。

4

3 に答える 3

2

これを変える

$query =  "SELECT (a.acode) as "access_id", (s.s_first_name) as "fname",      (s.s_middle_initial) as "mname", (s.s_last_name) as "lname", (a.s_email) as "email", (a.req_subj) as "subjcode"

$query =  "SELECT (a.acode) as 'access_id', (s.s_first_name) as 'fname',      (s.s_middle_initial) as 'mname', (s.s_last_name) as 'lname', (a.s_email) as 'email', (a.req_subj) as 'subjcode'
于 2013-05-03T08:50:05.410 に答える
0

これを試して

$query =  "SELECT (a.acode) as " . access_id . ", (s.s_first_name) as " . fname . ",      (s.s_middle_initial) as " . mname . ", (s.s_last_name) as " . lname . ", (a.s_email) as "email", (a.req_subj) as " . subjcode
于 2013-05-03T08:56:18.783 に答える