php 中mysql的查询语句

来源:百度知道 编辑:UC知道 时间:2024/05/06 00:27:09
我在做一论坛,实现显示会员留言和会员的头像下面是我写的核心代码
<?php
$query2="select * from note_info where id='$note_id'";
$result2=$aa->excu($query2);
$note2=mysql_fetch_array($result2);
?>
<?php
$query3="select picture from user_info where user_name= $note[user_name]";//就是这句查询语句不对,我是想用上面查询出来的user_name作为限制条件查询出相应的头像 这句话该怎么写啊 直接等于$note[user_name]不对啊,需要加什么符号吗?
$result3=$aa->excu($query3);
$note3=mysql_fetch_row($result3);
?>
小弟初学PHP 对mysql查询语句还不太了解,希望哪位大哥指教啊
纠正一下上面$query3=是写的$query3="select picture from user_info where user_name= $note2[user_name]";

$query3="select picture from user_info where user_name= '".$note2[user_name]."'";

应该是对的,

对于字符串的表示,在mysql中是需要加单引号的。
user_name = '$note2[user_name]';

希望我的回答对你有所帮助!

就是少个引号
'$note[user_name]'