mmarif4u Posted January 5, 2007 Share Posted January 5, 2007 Hi everybody..I am facing some problem to fetch data from two tables..I have two tables.one is loguser other is access.In loguser thier is icnumber and creationdate fields In access theiris acccode field now i want to print results from these twotables...i try the query but gives error...Error is (Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\Arif\Doc Drive\WWW\reg1\admin.php on line 159)And cannot print the results..while i have also code to insert it 1st to tables..Code are here:[code]<?php$con = mysql_connect("localhost","root","adil");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("db", $con);$query = ("SELECT loguser.icnumber,access.acccode,DATE_FORMAT(loguser.creationdate, '%d/%m/%Y')AS formatteddate, FROM loguser,access where icnumber = '$ic'");$result = mysql_query($query);echo "<table align=Center CELLSPACING='0'BORDERCOLOR='#007FFF' BGCOLOR='cornsilk' border='1'><tr><th colspan=12><Font face='Verdana'size='3'>User Activation Details</th></Font><tr><th><Font face='Verdana'size='2'>IC Number</th></Font><th><Font face='Verdana'size='2'>Access Code</th></Font><th><Font face='Verdana'size='2'>Date & Time</th></Font></tr></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td><Font face='Verdana'>" . $row['icnumber'] . "</td></font>"; echo "<td><Font face='Verdana'size='4'>" . $row['acccode'] . "</td></font>"; echo "<td><Font face='Verdana'>" . $row['formatteddate'] . "</td></font>"; echo "</tr>"; }echo "</table>";mysql_close($con);[/code]I try my best to overcome on this prob but cant can any one help me... Quote Link to comment Share on other sites More sharing options...
DaveEverFade Posted January 5, 2007 Share Posted January 5, 2007 You might want to run the query in PHPMyAmin first to make sure you are getting the results you expect. Or:print_r($result);That'll display the whole array of results with the other arrays also, might help you figure out what the problem is... Quote Link to comment Share on other sites More sharing options...
weknowtheworld Posted January 6, 2007 Share Posted January 6, 2007 Try to echo sql statement and run in phpmyadmin and check it out it returns values.. Quote Link to comment 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.