Home > Backend Development > PHP Tutorial > php在MYsql中查询的有关问题?

php在MYsql中查询的有关问题?

WBOY
Release: 2016-06-13 11:05:53
Original
931 people have browsed it

php在MYsql中查询的问题??
我想在数据中根据某个值查询对应的值.例:知道user的值然后显示pwd的值。我在phpamdin里面测试的代码是:

$sql = 'SELECT pwd'<br />        . ' FROM `appdata` '<br />        . ' WHERE user = \[email&#160;protected]\' LIMIT 0, 30';
Copy after login

但是加在php文件里面执行总是不成功。

下面是我的代码,怎么修改呢?
<?php<br />    include_once "logindatabase.php";<br />    $cmd = mysql_query(SELECT * FROM appdata WHERE user [email&#160;protected]);<br />    $rec = mysql_fetch_array($cmd);<br />    echo $rec[Pwd];<br />?>
Copy after login

谢谢大家~
------解决方案--------------------
    include_once "logindatabase.php";
    $cmd = mysql_query('SELECT * FROM appdata WHERE user="[email protected]"');
    $rec = mysql_fetch_array($cmd);
    //while($rec = mysql_fetch_array($cmd))
    echo $rec['Pwd'];
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template