php - What is the error in MySQL query.? -
i new php & mysql , getting error , don't understand error in query? allowing user fill form , submit. after form submitted should go in mysql database, on myphp code of insertion working right on website throwing me error.
this error getting:
error: have error in sql syntax; check manual corresponds mysql server version right syntax utilize near '@gmail.com), af_name = values('name of person'), v_city = valu' @ line 7
and after submitting form moved php page. want remain on page form present. code & form on different php pages.
this code:
<?php $con = mysql_connect(host, user_name, password, db_name); if (!$con) { die('could not connect: ' . mysql_error()); } mysql_select_db("user", $con); $sql="insert request (rf_name, rl_name, r_email, af_name, v_city, v_country, time, date, message) values ('$_post[rfname]', '$_post[rlname]', '$_post[sender]', '$_post[afname]', '$_post[vcity]', '$_post[vcountry]', '$_post[time]', '$_post[date]', '$_post[body]') on duplicate key update rf_name = values($_post[rfname]), rl_name = values($_post[rlname]), r_email = values($_post[sender]), af_name = values($_post[afname]), v_city = values($_post[vcity]), v_country = values($_post[vcountry]), time = values($_post[time]), date = values($_post[date]), message = values($_post[body])"; if (!mysql_query($sql,$con)) { die('error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?>
enclose values in quotes when updating:
rf_name = values('$_post[rfname])', rl_name = values('$_post[rlname]'), r_email = values('$_post[sender]'), af_name = values('$_post[afname]'), v_city = values('$_post[vcity]'), v_country = values('$_post[vcountry]'), time = values('$_post[time]'), date = values('$_post[date]'), message = values('$_post[body]') php mysql
No comments:
Post a Comment