saran.tvmalai Posted September 6, 2010 Share Posted September 6, 2010 <?php session_start(); if (!$_SESSION["user_name"]) { // User not logged in, redirect to login page Header("Location: login.php"); } // Member only content // ... $con = mysql_connect('localhost','root',''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); $result = mysql_query("select * from reference,users where reference.username=users.user_name AND reference.refid = '".$_POST['refid']."'"); while($row = mysql_fetch_array($result)) { echo $row['refid'];?><br><? echo $row['origin']; echo $row['dest']; echo $row['date']; echo $row['exdate']; echo $row['user_name']; } // ... // ... // Display Member information // echo "<p>User ID: " . $_SESSION["valid_id"]; //echo "<p>Username: " . $_SESSION["valid_user"]; //echo "<p>Logged in: " . date("m/d/Y", $_SESSION["valid_time"]); // Display logout link echo "<p><a href=\"logout.php\">Click here to logout!</a></p>"; ?> for the above code i got error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in solve my problem Quote Link to comment https://forums.phpfreaks.com/topic/212649-resolve-my-php-problem/ Share on other sites More sharing options...
wildteen88 Posted September 6, 2010 Share Posted September 6, 2010 That error usually indicates there is a problem with your query. Change this $result = mysql_query("select * from reference,users where reference.username=users.user_name AND reference.refid = '".$_POST['refid']."'"); To $query = "select * from reference,users where reference.username=users.user_name AND reference.refid = '".$_POST['refid']."'"; $result = mysql_query($query) or trigger_error('MySQL encountered a problem<br />Error: ' . mysql_error() . '<br />Query: ' . $query); Run the code and post the error here Quote Link to comment https://forums.phpfreaks.com/topic/212649-resolve-my-php-problem/#findComment-1107778 Share on other sites More sharing options...
ocpaul20 Posted September 6, 2010 Share Posted September 6, 2010 What have you done yourself to resolve your problem? What I do, is to work through each point in the program which is causing an error. So for example if an SQL statement is causing an error, I put a literal into the statement and run it in a SQL query browser (independent and outside of the program). Once that is working then I make sure that the statement in the program is working. That usually gets me past the bug. check the database is open correctly and the statement is working. Quote Link to comment https://forums.phpfreaks.com/topic/212649-resolve-my-php-problem/#findComment-1107780 Share on other sites More sharing options...
saran.tvmalai Posted September 6, 2010 Author Share Posted September 6, 2010 i got this below error again Notice: MySQL encountered a problem Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (latin1_general_ci,IMPLICIT) for operation '=' Query: select * from reference,users where reference.username=users.user_name AND reference.refid = '12345' in Quote Link to comment https://forums.phpfreaks.com/topic/212649-resolve-my-php-problem/#findComment-1107781 Share on other sites More sharing options...
wildteen88 Posted September 6, 2010 Share Posted September 6, 2010 Only strings should be wrapped in quotes. Change this $queyr = "select * from reference,users where reference.username=users.user_name AND reference.refid = '".$_POST['refid']."'"; to $query = "select * from reference,users where reference.username=users.user_name AND reference.refid = ". intval($_POST['refid']); Quote Link to comment https://forums.phpfreaks.com/topic/212649-resolve-my-php-problem/#findComment-1107785 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.