garteth Posted July 11, 2011 Share Posted July 11, 2011 Can anyone tell me how I would need to change my query so that I can use require_once('mysql_connect.php'); instead of having to write my database details into the php file. $result = mysql_query("SELECT * FROM smsaudit WHERE smsuser = '" . $_SESSION['SESS_SMS_USER'] . "'"); while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . strrev($row['smsident']). "</td>"; echo "<td>" . $row['smsuser'] . "</td>"; echo "<td>" . $row['smsdest'] . "</td>"; echo "<td>" . $row['smsreply'] . "</td>"; echo "<td>" . $row['smsidentifier'] . "</td>"; echo "<td>" . $row['smsorigip'] . "</td>"; echo "<td>" . $row['smstext'] . "</td>"; echo "</tr>"; } echo "</table>"; echo "</br>"; ?> currently I am connecting like so: mysql_connect ("#####", "#####","######") or die (mysql_error()); mysql_select_db("#####"); Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 11, 2011 Share Posted July 11, 2011 You don't need to change your query? :S You just need to put the "include 'file';" at the top of the page? :S Quote Link to comment Share on other sites More sharing options...
garteth Posted July 11, 2011 Author Share Posted July 11, 2011 Really because when I write include ('connect.php'); at the top I get this message: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in Quote Link to comment Share on other sites More sharing options...
Andy11548 Posted July 11, 2011 Share Posted July 11, 2011 Show me your connect.php page Also, show me the full page with the problem, also, wrap the code in ['code] tags.['/code] take out the ' in the tags. Quote Link to comment Share on other sites More sharing options...
IrOnMaSk Posted July 11, 2011 Share Posted July 11, 2011 Hey Garteth your question is a bit confusing the error code has nothing to do with your connection to the database. your mysql_query is giving you the error. So if you want to use the require once or the include for you connection... you need to put this code mysql_connect ("#####", "#####","######") or die (mysql_error()); mysql_select_db("#####"); in connect.php file... and at the top of your query code include it or require the file there, then you don't have to keep writing the detail connection to the database... concerning the error, recheck your mysql_query statement.... goodluck Quote Link to comment Share on other sites More sharing options...
garteth Posted July 12, 2011 Author Share Posted July 12, 2011 Ironmask you were 100% correct, cannot believe that I did not see that. Thanks very much for everyone's help 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.