Jump to content

Cannot do a query?


DarrenReeder

Recommended Posts

HEllo,

 

I have connected to my database with "#include ("Connections.php");" at top of my code, and it connects perfectly with no error, Although when i try to run a query i get errors...THis is my connection.php and the query in the index.html Respectively....

 

<?php
session_start();

$host="localhost";
$username="root";
$password="";
$db_name="up";


//connect to database
mysql_connect("$host","$username","$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select Database");

//login check function
function loggedin()
{
if (isset($_SESSION['username']))
{
$loggedin = true;
return $loggedin;

}
}

function IsAdmin()
{
$realname =$_SESSION['username'];
$query="select * FROM accounts WHERE username ='$realname'";
$result=mysql_query($query);
$num=mysql_num_rows($result);

$rows=mysql_fetch_array($result);
$admin=$rows['Admin'];
if ($admin >= 1)
{
$IsAdmin = true;
return $IsAdmin;

}
}


?>

 

	$query=mysql_query("SELECT * FROM accounts WHERE username='darren'");
$row=mysql_num_rows($query);
}
if($row==0)
{
echo"Yes";
}
if($row==1)
{
echo"Name already taken!!";
}

 

And this is the errors..

 

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\UniversalProgramming\Register.php on line 67

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\UniversalProgramming\Register.php on line 67

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\UniversalProgramming\Register.php on line 68

 

Now this is very strange because as you can see i use those if statements...and they work perfectly but i still get Errors on the queries.. So help me please :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.