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
https://forums.phpfreaks.com/topic/241662-mysql-connect/
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
https://forums.phpfreaks.com/topic/241662-mysql-connect/#findComment-1241363
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.