Tech Support Guy banner
Status
Not open for further replies.
1 - 11 of 11 Posts

· Registered
Joined
·
36 Posts
Discussion Starter · #1 ·
Hey, I watched the 3D Buzz php&mysql series like 10 times. Love the tutorials.

I got apache php and mysql very easily set up but I am having a problem with require.

My php works when I do arithmetics, or date, or printing stuff but not with require. This code is an example from 3DBuzz.com tutorials for practicing php.

<?php
require($_SERVER['DOCUMENT_ROOT'].'/config/config.php');
$connection=mysql_connect($db_host, $db_user, $db_password) or die("error");

echo $db_host;
?>

This is what I put, and theoretically it should print for me $db_host defined in config/config.php. But it doesn't. It doesn't show anything. Infact if I include this code with HTML documents, the HTML won't show either.

Has the syntax for document_root changed for later versions of PHP?

What is the problem? I even shut off my firewall etc. No good.

The only thing I can think of is my root is in C: so is my PHP folder, my apache and MySQL are in program files in their default places. maybe mysql_connect (); doesnt know where to look for the monitor? help please!
 

· Registered
Joined
·
36 Posts
Discussion Starter · #4 ·
EDIT: actually it doesnt matter about the slashes.

it has a problem with the lines

$connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting");

when i add this into the code it screws up. not sure whats wrong with it.
 

· Registered
Joined
·
36 Posts
Discussion Starter · #6 ·
is the function mysql_connect(); from PHP 5.2.0? I don't think it is included because when I add the mysql_connect to the code thats when nothing appears on the page. It doesn't interact with mysql on my computer.

EDIT: YUP my script is terminating at mysql_connect.' anything before it will print.

help me.
 

· Registered
Joined
·
15,981 Posts
Is there no error printed?
You may need to add
PHP:
error_reporting(E_ALL);
to the beginning of your script to show the error messages.

You also might not have compiled PHP with MySQL support - it's no longer built-in by default. You can run phpinfo() and look for a "MySQL" section to find out.
 
1 - 11 of 11 Posts
Status
Not open for further replies.
Top