这是我的一段代码:
<?php

$store_poster=$_POST['poster'];
$store_title=$_POST['title'];
$store_message=$_POST['message'];
$store_parent=$_POST['parent'];(parent 是个数字,其它的都是字符串)

//check not a duplicate
$conn=mysql_connect('localhost','root','lvliangwei'); mysql_select_db('lvyou', $conn) or die ('Can\'t use lvyou : ' . mysql_error());

$query="select header.postid from header ,body where 
header.postid=body.postid and 
header.parent=".$store_parent." and
header.poster='".$store_poster."' and
header.title='".$store_title."' and
body.message='".$store_message."'";

$result=mysql_query($query)or die("invalid query:  " . mysql_error());

if(!$result){return false;}

$num_rows=mysql_num_rows($result);

在浏览器中运行时出现入下提示:
invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and header.poster= and header.title= and body.message='
这是怎么回事 我的$query语句赋值有错么?

解决方案 »

  1.   

    $store_poster $store_title $store_message 都是空
    你把那些值給上
      

  2.   

    语句是没有问题,应该是你插入的值的问题。可能是没有将值addslashes。
    值里有特殊字符。
      

  3.   

    是不是你表单 GET过来的?
      

  4.   

    这些值都是我从上一个页面中post过来的,<form action="***" method="post">“将值addslashes” 是什么意思?各位能解释一下么?
      

  5.   

    搞定了,是我插入的字段写错了,数据库中就没有$poster 一项!!
    谢谢各位!!!