我该怎么做才能解决此错误 [英] What can I do get this error fix
本文介绍了我该怎么做才能解决此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
我有这个错误,我真的不知道如何解决它。
这是错误
解析错误:语法错误,意外' mysqli_error'(T_STRING) C:\ wamp64 \过网站上的#luana_itec244 \\\ [@ b
这是错误的来源
我尝试过:
< pre > <? php
if(isset( $ _POST [' submit']))
{
// 从表单中捕获变量并存储在php变量中
$ title = $ _ POST [' title'];
$ firstname = $ _ POST [' firstname'];
$ lastname = $ _ POST [' lastname'];
$ address = $ _ POST [' address'];
$ txtemail = $ _ POST [' txtemail'];
$ gender = $ _ POST [' gender'];
$ userName = $ _ POST [' userName'];
$ pword = $ _ POST [' pword'];
// 连接服务器
$ db_host = localhost;
$ db_username = root;
$ db_password = ;
$ con = mysqli_connect($ db_host,$ db_username,$ db_password)或 die(mysqli_connect_error) ());
// 选择要查询的数据库
mysqli_select_db($ con,' food')或 die(mysqli_error($ con));
$ sql = SELECT * FROM member WHERE userName ='$ userName';
$ result = mysqli_query($ con,$ sql)或 die( 错误: mysqli_error());
$ rowcount = mysqli_num_rows($ result);
if($ rowcount> = 1)
{
echo < script type = \text / javascript \;
alert('用户名已存在');
窗口。 location = \register.html \;
< / script>;
}
其他
{
// < span class =code-comment>将数据插入表中
$ sql = INSERT INTO成员
VALUES('$ title','$ firstname','$ lastname','$ address','$ txtemail' ,'$ gender','$ userName',MD5('$ pword'));
if(mysqli_query($ con,$ sql))
{
mysqli_close($ con);
header( location:welcome.php);
}
else
{
echo 插入数据库时出错 .mysqli_error($ con);
}
}
}
?>
解决方案
_POST [' submit']))
{
// 从表单中捕获变量并存储在php变量中
title =
_POST [' title'];
hi
i have this error and I really dont know how to go about fix it.
this is the error
Parse error: syntax error, unexpected 'mysqli_error' (T_STRING) in C:\wamp64\www\luana_itec244\php\register.php on line 2
this is where the error is coming from
What I have tried:
<pre><?php
if(isset($_POST['submit']))
{
//capture the variable from the form and store in php variables
$title=$_POST['title'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$address=$_POST['address'];
$txtemail=$_POST['txtemail'];
$gender=$_POST['gender'];
$userName=$_POST['userName'];
$pword=$_POST['pword'];
//connecting to the server
$db_host="localhost";
$db_username="root";
$db_password="";
$con = mysqli_connect($db_host,$db_username,$db_password) or die (mysqli_connect_error());
//select the database you want to query
mysqli_select_db($con, 'food') or die (mysqli_error($con));
$sql = "SELECT * FROM member WHERE userName = '$userName'";
$result=mysqli_query($con,$sql) or die("error:" mysqli_error());
$rowcount=mysqli_num_rows($result);
if($rowcount >= 1)
{
echo "<script type=\"text/javascript\";
alert('username already exist');
window.location=\"register.html\";
</script>";
}
else
{
//insert data into table
$sql = "INSERT INTO member
VALUES('$title', '$firstname', '$lastname', '$address', '$txtemail', '$gender', '$userName', MD5('$pword'))";
if(mysqli_query($con, $sql))
{
mysqli_close($con);
header("location:welcome.php");
}
else
{
echo "Error inserting into database".mysqli_error($con);
}
}
}
?>
解决方案 _POST['submit']))
{
//capture the variable from the form and store in php variables
title=
_POST['title'];
这篇关于我该怎么做才能解决此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文