I am sending info from my login form to the processLogin.php page, which in turn logs me in and everything, and then is supposed to write new info to the relevant div which sent the call.
But my processLogin page started saying it "couldn't connect to the localhost", which most definitely is not my intent nor have it set it to. So I included the connect.php page on the page itself; nothing. It still had a mistake (occurring right at my first query). So I wrote the connection info directly before the query, and no longer receive that error, but still no data. I echo'd the query and get nothing. So, here is the connect.php code I include in index.php, so it can call it each time:
[PHP]<?php
$dbServer = 'mysql***.secureserver.net';
$dbDatabase = '****;
$dbUser = '****';
$dbPass = '****';
// Connect to database
$db = mysql_pconnect($dbServer, $dbUser, $dbPass) or die("Couldn't connect to database due to error in page: " . mysql_error());
mysql_select_db($dbDatabase, $db) or die("Couldn't select database due to error in page: " . mysql_error()); ?>[/PHP]
Neither of these error message ever appear, btw, meaning the connection is working here.
Here is the code that is throwing the error:
[php]$sql = mysql_query("SELECT * FROM users WHERE username=" . $username . " AND password=" . $password . " AND activated='1'");
echo 'sql=' . $sql;
$login_check = mysql_num_rows($sql);[/php]
Where I echo sql=$sql, I get "sql=" and nothing else, and this is the error message:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /blahblahblah on line 51.And finally, when I include the connect info instead of writing it straight to the page (and I'm including it to the page, as opposed to index.php [where I normally include it]):
Warning: mysql_query(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /webpage on line 47Sorry for the lengthy first post, but I wanted to get all relevant info out there.
My guess is it's because I'm calling for the page through ajax, but I can't figure out how that causes the problem or how to fix it. Any ideas or help MUCH appreciated!