DarrenReeder Posted December 17, 2009 Share Posted December 17, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/185439-cannot-do-a-query/ Share on other sites More sharing options...
DarrenReeder Posted December 17, 2009 Author Share Posted December 17, 2009 Btw, the reason it says username='darren' was so i could test it to see if the Post variable was messing up ($_POST[username]) Quote Link to comment https://forums.phpfreaks.com/topic/185439-cannot-do-a-query/#findComment-978992 Share on other sites More sharing options...
PFMaBiSmAd Posted December 17, 2009 Share Posted December 17, 2009 #include ("Connections.php"); The # makes that line a comment and it is not including anything at all. Quote Link to comment https://forums.phpfreaks.com/topic/185439-cannot-do-a-query/#findComment-979129 Share on other sites More sharing options...
DarrenReeder Posted December 17, 2009 Author Share Posted December 17, 2009 so how do i include it? Quote Link to comment https://forums.phpfreaks.com/topic/185439-cannot-do-a-query/#findComment-979208 Share on other sites More sharing options...
rajivgonsalves Posted December 17, 2009 Share Posted December 17, 2009 include ("Connections.php"); Quote Link to comment https://forums.phpfreaks.com/topic/185439-cannot-do-a-query/#findComment-979217 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.