
carylson
Members-
Posts
11 -
Joined
-
Last visited
Never
Everything posted by carylson
-
Im not sure if I'm using mysql_fetch_array() and mysql_query() correctly. I get mysql errors on the following line: $UserInfo = mysql_fetch_array(mysql_query("SELECT * FROM Users WHERE Username = '". $_REQUEST['frmUsername'] ."' && Password = '". $_REQUEST['frmPassword'] ."'")); Can anybody help? Thanks! The rest of the code: <?php if ($_REQUEST['fcn'] == "login") { if ($_REQUEST['frmUsername'] == "" || $_REQUEST['frmPassword'] == "") { echo "Invalid login. Please complete all form data and try again."; } else { $UserInfo = mysql_fetch_array(mysql_query("SELECT * FROM Users WHERE Username = '". $_REQUEST['frmUsername'] ."' && Password = '". $_REQUEST['frmPassword'] ."'")); 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 ...
-
3306 is the default socket- it shouldn't make a difference if its there or not. tried it anyway and get the same error
-
perhaps you could make a suggestion if you DO know what to do.
-
gave localhost a try and it resulted in identical errors. not sure if thats good or bad...
-
But there is. I changed the code and wanted to avoid confusion.
-
Im not sure why I am receiving this error, any help is appreciated: Output: 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 12 Warning: mysql_query(): A link to the server could not be established in /hsphere/local/home/dtsabai/parrecsol.com/cp/login.php on line 12 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 13 Invalid login. The specified user could not be found. Please double check your information and try again. 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 12/13: $UserInfoSQL = mysql_query("SELECT * FROM Users WHERE Username = '". $_REQUEST['frmUsername'] ."' AND Password = '". $_REQUEST['frmPassword'] ."'"); $UserInfo = mysql_fetch_array($UserInfoSQL);
-
added that in; as no output changed it would seem to me that my connection is valid. any other suggestions?
-
How do I verify my database connection?
-
Appoligies; this file is included into another containing the dtabase connection. I appended the connection info into the original message.
-
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);
-
Returns the following error: Parse error: syntax error, unexpected '[', expecting ',' or ';' in /hsphere/local/home/dtsabai/parrecsol.com/cp/index.php on line 47 The Code: <?php include("top.php"); if ($_SESSION['LoggedIn'] != True) { $_SESSION['msg'] = "Please login before accessing your account."; header('Location: login.php'); } if ($_SESSION['AdminLevel'] == "Full") { $SelectorFilter = " WHERE Status = 'Open'"; } else { $SelectorFilter = " WHERE Status = 'Open' AND UserID = ". $_SESSION['ID']; } if ($_REQUEST['fcn'] == "updateinfo") { if ($_REQUEST['frmPassword'] != "" && $_REQUEST['frmEmail'] != "") { $UpdateInfoSQL = "UPDATE Users SET Password = '". $_REQUEST['frmPassword'] ."', Email = '". $_REQUEST['frmEmail'] ."' WHERE ID = ". $_SESSION['ID']; mysql_query($UpdateInfoSQL); $_SESSION['msg'] = "Information updated successfully."; header('Location: index.php'); } else { $_SESSION['msg'] = "Inclomplete form. Please fill out all fields and try again."; header('Location: index.php'); } } $UserInfoSQL = "SELECT * FROM Users WHERE ID = ". $_SESSION['ID']; $UserInfo = mysql_fetch_array(mysql_query($UserInfoSQL)); if (isset($_SESSION['msg'])) { echo "<p align=center><font color=red><strong>". $_SESSION['msg'] ."</strong></font></p>"; $_SESSION['msg'] = ""; } ?> ...A bunch of HTML here... Line 47 snippet below. Line 47: <td width="400px"><?=UserInfo['ID']?></td> This problem is driving me crazy so if anybody has any suggestions it would be greatly appreciated! Aaron