Database Connect
-
I have put a bit of PHP in with Insert PHP and it runs fine. Since it is a database connect, I don’t want it in the page for obvious reasons:
[insert_php] $$db=mysql_connect ("localhost", "USER", "PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("DATABASE");global $$db;$asql=mysql_query("SELECT * FROM rates WHERE r_id='1'") or die(mysql_error());$arow=mysql_fetch_array($asql); [/insert_php]
I want to put it in a file and pull it in, but when I do, it just prints the file contents. I tried this code:
[insert_php] $FileLocation = "/wp/dbcon.php"; readfile($_SERVER['DOCUMENT_ROOT'].$FileLocation); [/insert_php]
There are additions down the page that print the data, which work fine with the first database connect statement above. For example:
[insert_php]echo $arow[‘r_reg’];[/insert_php]
I have tried making the file with and without the <?php and ?>, same results.
Any ideas??
Thanks in advance.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Database Connect’ is closed to new replies.