carylson Posted January 3, 2008 Share Posted January 3, 2008 Im not sure why I am receiving this error, any help is appreciated: The error: Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /hsphere/local/home/dtsabai/parrecsol.com/cp/login.php on line 13 Warning: mysql_query(): A link to the server could not be established in /hsphere/local/home/dtsabai/parrecsol.com/cp/login.php on line 13 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/dtsabai/parrecsol.com/cp/login.php on line 14 The Code: <?php $dbhost = 'mysql401.ixwebhosting.com:3306'; $dbuser = '***'; $dbpass = '***'; $dbname = '***'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); if ($_REQUEST['fcn'] == "login") { if ($_REQUEST['frmUsername'] == "" || $_REQUEST['frmPassword'] == "") { echo "Invalid login. Please complete all form data and try again."; } else { $UserInfoSQL = mysql_query("SELECT * FROM Users WHERE Username = '". $_REQUEST['frmUsername'] ."' AND Password = '". $_REQUEST['frmPassword'] ."'"); $UserInfo = mysql_fetch_array($UserInfoSQL); if ($UserInfo) { $_SESSION['LoggedIn'] = True; $_SESSION['ID'] = $UserInfo['ID']; $_SESSION['Username'] = $UserInfo['Username']; $_SESSION['AdminLevel'] = $UserInfo['AdminLevel']; echo "Login successful. Hello, ". $_SESSION['Username'] ."!"; } else { echo "Invalid login. The specified user could not be found. Please double check your information and try again."; } } } ?> .... some html Lines 13/14: $UserInfoSQL = mysql_query("SELECT * FROM Users WHERE Username = '". $_REQUEST['frmUsername'] ."' AND Password = '". $_REQUEST['frmPassword'] ."'"); $UserInfo = mysql_fetch_array($UserInfoSQL); Quote Link to comment https://forums.phpfreaks.com/topic/84213-clueless-please-help/ Share on other sites More sharing options...
neilfurry Posted January 3, 2008 Share Posted January 3, 2008 it seems that you have problem connecting to your database server, please check your username,password and host. Quote Link to comment https://forums.phpfreaks.com/topic/84213-clueless-please-help/#findComment-428830 Share on other sites More sharing options...
roopurt18 Posted January 3, 2008 Share Posted January 3, 2008 I don't see anywhere in your code where you've connected to the database with mysql_connect(). Neither do a I see reference to an include or require file that might do so. Bottom line: You must connect to the database before you can run queries against it. Quote Link to comment https://forums.phpfreaks.com/topic/84213-clueless-please-help/#findComment-428831 Share on other sites More sharing options...
carylson Posted January 3, 2008 Author Share Posted January 3, 2008 Appoligies; this file is included into another containing the dtabase connection. I appended the connection info into the original message. Quote Link to comment https://forums.phpfreaks.com/topic/84213-clueless-please-help/#findComment-428834 Share on other sites More sharing options...
carylson Posted January 3, 2008 Author Share Posted January 3, 2008 How do I verify my database connection? Quote Link to comment https://forums.phpfreaks.com/topic/84213-clueless-please-help/#findComment-428849 Share on other sites More sharing options...
revraz Posted January 3, 2008 Share Posted January 3, 2008 Here $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname) or die ('Unable to select DB'); Quote Link to comment https://forums.phpfreaks.com/topic/84213-clueless-please-help/#findComment-428852 Share on other sites More sharing options...
carylson Posted January 3, 2008 Author Share Posted January 3, 2008 added that in; as no output changed it would seem to me that my connection is valid. any other suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/84213-clueless-please-help/#findComment-428858 Share on other sites More sharing options...
dewey_witt Posted January 3, 2008 Share Posted January 3, 2008 *BUMP* Quote Link to comment https://forums.phpfreaks.com/topic/84213-clueless-please-help/#findComment-428937 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.