我的查询:
$near = ('select id,
first,
last,
trainer_address1,
CITY,
STATE,
trainer_zip
from event.A.trainer where trainer zip ='.($_GET['zip1']));
echo lookup_gen::query_results_table($near, matry::here_to('edit'));
echo "<pre>"; print_r ($near); echo "</pre>";
当我print_r时,除了zip1的$_GET
变量外,所有内容都为空。像这样:
select id,
first,
last,
trainer_address1,
CITY,
STATE,
trainer_zip
from event.A.trainer where trainer zip =92054
如果我删除$_GET变量并硬编码邮政编码,它可以正常工作:
$near = ("select id,
first,
last,
trainer_zip
from event.A.trainer where trainer_zip = '66415'");
echo lookup_gen::query_results_table($near, matry::here_to('edit'));
我使用$_GET变量错误吗?此外,如果有人对lookup_gen::query_results_table感兴趣,我将发布该函数的代码。
我希望这是有意义的,我当然希望有人能帮助我。谢谢你。这个为我工作:
$near = ("select id,
first,
last,
trainer_zip
from event.A.trainer where trainer_zip ='".($_GET['zip1']."'"));
echo lookup_gen::query_results_table($near, matry::here_to('edit'));
你需要用单引号把变量括起来,所以应该是
$zip = mysql_real_escape_string($_GET['zip1']);
$near = "select id, first, last, trainer_address1, CITY, STATE, trainer_zip "
"from event.ACS.trainer where trainer zip ='{$zip}'";