Jump to content

can not understand this error


funbinod

Recommended Posts

the following line--

mysqli_query($connect, $sql) or die('Error: ' . mysql_error());

works for

$connect = mysql_connect($db_host, $db_user, $db_pass);if (!$connect) die("Unable to connect to database: " . mysql_error());$sql = ("INSERT INTO customer (cname, cadd, cemail, cphone, cperson, cmob, cob)VALUES ('$_POST[cname]', '$_POST[cadd]', '$_POST[cemail]', '$_POST[cphone]', '$_POST[cperson]', '$_POST[cmob]', '$_POST[cob]')");

but doesnot work for

$connect = mysql_connect($db_host, $db_user, $db_pass);if (!$connect) die("Unable to connect to database: " . mysql_error());$sql = ("INSERT INTO vender (vname, vadd, vemail, vphone, vperson, vmob, vob)VALUES ('$_POST[vname]', '$_POST[vadd]', '$_POST[vemail]', '$_POST[vphone]', '$_POST[vperson]', '$_POST[vmob]', '$_POST[vob]'");

& gives error message ---

Warning: mysqli_query() expects parameter 1 to be mysqli, resource given in E:xampphtdocsacpandavvregisterpost.php on line 63

i couldnt understand why!
Link to comment
Share on other sites

This issue is slightly different. You're connecting with mysql_connect, and querying with mysqli_query. You are mixing mysql and mysqli. Other than that, your code is completely vulnerable to SQL injection attacks and does not do any validation at all. You should be using prepared statements with mysqli instead of putting things from $_POST or $_GET straight into your queries.

Link to comment
Share on other sites

thank u all. i got the point and i edited that and made it work.

 

but at another point got another problem

$payment = mysqli_query($connect, "SELECT sum(amt) FROM payment WHERE vid='$row[vid]'") or die(mysqli_errno());

and got this message--

Warning: mysqli_errno() expects exactly 1 parameter, 0 given in E:xampphtdocsacpandavvregister.php on line 109

 

but the same line on another page doesnt show any warning and works properly..

Link to comment
Share on other sites

thank u all again. and i found the problem now. it was mistake on column name of database. but thank u for helping me understand basics of mysqli. now am trying to write everything on mysqli.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...