mysqli insert issue

My first mysqli insert attempt

error is: [09-Nov-2013 17:51:42] PHP Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/foode/public_html/adduser.php on line 9

form is

[php]

<h3>First Name:</h3>
<input type="text" name="post_firstname">
<h3>Last Name:</h3>
<input type="text" name="post_lastname">
<h3>Email Address:</h3>
<input type="text" name="post_email">
<h3>City:</h3>
<input type="text" name="post_city">
<h3>State:</h3>
<input type="text" name="post_state">
<h3>How Often Email Choice 1:</h3>
<input type="text" name="post_increment1">
<h3>Email Times Choice 2:</h3>
<input type="text" name="post_increment2">
<h3>Your Text Phone Number & Carrier (Sprint, At&T, etc):</h3>
<input type="text" name="post_smsadd">
<h3>Type Of Email:</h3>
<input type="text" name="post_type1">
<h3>Second Type Of Email:</h3>
<input type="text" name="post_type2">
<h3>Preferred Group:</h3>
<input type="text" name="post_group1">
<h3>Preferred Group 2:</h3>
<input type="text" name="post_group2">

<input type="submit">
[/php]

login is

[php]<?php
function login()
{
$con = mysqli_connect(“localhost”, “foode_pub”, “none99$”) or die(‘Could not connect to server’);
mysqli_select_db(“food_db1”, $con) or die(‘Could not connect to database’);
}
?>[/php]

adduser is

[php]<?php
include(“login.php”);
?>

<?php mysqli_query("INSERT INTO products users (firstname, lastname, email, city, state, increment1, increment2, smsadd, type1, type2, group1, group2) VALUES ('$_POST[post_firstname]', '$_POST[post_lastname]', '$_POST[post_email]', '$_POST[post_city]', '$_POST[post_state]', '$_POST[post_increment1]', '$_POST[post_increment2]', '$_POST[post_smsadd]', '$_POST[post_type1]', '$_POST[post_type2]', '$_POST[post_group1]', '$_POST[post_group2]')"); $result = mysqli_query($query) or die('Unable to add'); if ($result) echo "

New user added

\n"; else echo "

Problem adding new product

\n"; ?>[/php]

Thanks for any thoughts.

If you don’t write OOP then you must send in the mysqli connection with each query.
http://us2.php.net/mysqli_query

Sponsor our Newsletter | Privacy Policy | Terms of Service