嘿伙计们,请你帮我找到这个特殊代码中的任何错误我是php新手我不太了解但是错误是
解析错误:语法错误,意外'$ sql_query'(T_VARIABLE)
<?php
require"init.php";
$user_name = "Nikhil123";
$user_pass = "Sawant"
$sql_query = "select name from user_info where username like '$user_name' and userpass like '$user_pass' ;" ;
$result = mysqli_query($con,$sql_query);
if(mysqli_num_rows($result)>0)
{
$row = mysqli_fetch_assoc($result);
$name = $row("name");
echo "<h3> HELLO welcome".$name "</h3>";
}
else
{
echo "No INFO";
}
?>
答案 0 :(得分:2)
在;
之后添加$user_pass = "Sawant"
。在.
中的$name
和"</h3>";
之间添加echo "<h3> HELLO welcome".$name "</h3>";
:
<?php
require"init.php";
$user_name = "Nikhil123";
$user_pass = "Sawant";
$sql_query = "select name from user_info where username like '$user_name' and userpass like '$user_pass' ;" ;
$result = mysqli_query($con,$sql_query);
if(mysqli_num_rows($result)>0)
{
$row = mysqli_fetch_assoc($result);
$name = $row("name");
echo "<h3> HELLO welcome".$name ."</h3>";
}
else
{
echo "No INFO";
}
?>
答案 1 :(得分:-1)
使用单引号代替&#34; ...&#34;对于sql - 即&#39;选择...&#34;&#39;。$ var。&#39;&#34; ....&#39 ;;
$ sql_query =&#39;从user_info中选择名称,其中包含&#34;&#39;。$ user_name。&#39;&#34;和userpass类似&#34;&#39;。$ user_pass。&#39;&#34; ;&#39; ;