PHP mysqli_query() expects at least 2 parameters, 1 given

I getting this error help needed urgent!!!

Warning: mysqli_query() expects at least 2 parameters, 1 given in /storage/h2/401/535401/public_html/register.php on line 80

Warning: mysqli_error() expects exactly 1 parameter, 0 given in /storage/h2/401/535401/public_html/register.php on line 80

[php]<?php

/* Don’t show private info even if it’s for a local server, for it could potentially trip you up in the future */
$con = mysqli_connect(‘localhost’,‘id535401_root’,‘username’,‘password’)or die(“Could not connect to mysql”.mysqli_error($con));

function NewUser()
{
$username = $_POST[‘username’];
$email = $_POST[‘useremail’];
$password = $_POST[‘password’];
$query = “INSERT INTO members (username,email,password) VALUES (’$username’,’$email’,’$password’)”;
$data = mysqli_query($con, $query) or die(mysqli_error());
if($data)
{
echo “YOUR REGISTRATION IS COMPLETED…”;
}
}

function SignUp()
{
if(!empty($_POST[‘username’])) //checking the ‘user’ name which is from Sign-Up.html, is it empty or have some text
{
$query= mysqli_query(“SELECT * FROM members WHERE username = ‘$_POST[username]’ AND password = ‘$_POST[password]’”) or die(mysqli_error());

if(!$row = mysqli_fetch_array($query) or die(mysqli_error()))
{
newuser();
}
else
{
echo “SORRY…YOU ARE ALREADY REGISTERED USER…”;
}
}
}
if(isset($_POST[‘submit’]))
{
SignUp();
}[/php]

Well, one of your errors is that you are using functions and the scope of your database connection fails (Think of functions as independent scripts that need variables that are set and that is what $con is). I don’t have time, but I’m pretty sure there are other problems to this script as well. Maybe someone else will chime in?

Sponsor our Newsletter | Privacy Policy | Terms of Service