Jump to content

MySQL Connect


garteth

Recommended Posts

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("#####");

Link to comment
Share on other sites

Hey Garteth your question is a bit confusing  :shrug:

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 :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.