Welcome! Log In Create A New Profile

Advanced

includez

Posted by theSinthesizer 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar includez
September 20, 2010 04:32PM
hi guyz,

i'm having a problem including an include. the file is saved in the includes folder as instructed in letter.
I refer to the file with a relative path (DUH!!!) as so
Language: PHP
include "includes/server_connection.php";
but I get an error.

Advice mad welcome. smile
avatar
Mac
Re: includez
September 21, 2010 06:57AM
braketz required.....!
avatar Re: includez
September 21, 2010 11:51AM
@mac,

i did as u said but i'm still getting the error.

The weird thing is that the page works when i have the code in the include written directly in the page.

Could it have to do with the server setup? And if it does, then how come the page works when the code in the include is written directly into the page?

>>>
The One that owns The Technology rulez the world!
Re: includez
September 27, 2010 07:47AM
What error are you getting?
avatar
Mac
Re: includez
September 27, 2010 09:26AM
Yip, thought I posted this same question back then but clearly it did not get published. It is like asking me to tell you why your car won't start this morning smiling smiley
avatar Re: includez
September 27, 2010 05:16PM
yo rogerdurbs,

i'm getting a failed to connect error.

including config.php works but i don't get why including the connection file won't work. angry smiley

>>>
The One that owns The Technology rulez the world!
avatar
Mac
Re: includez
September 28, 2010 07:49AM
This still does not help much sad smiley What does your connection code look like? Is MySQL running?

Read this: http://www.apachefriends.org/f/viewtopic.php?p=141499
Re: includez
September 28, 2010 09:08AM
First thing id try is comment out all the code in your config.php file and just put
Language: PHP
echo "test";

Then when you run the page you should get a test on the page, if you do then you know its something in your config.php thats a problem, if not then its the include syntax that has an issue.
avatar Re: includez
September 29, 2010 10:38AM
@roger,

i put echo "test" and it did echo it.

This is what i'm gettting when i try to connect:

/*connecting to the server & database*/ $link_id = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS); mysql_select_db(SQL_Dcool smiley; /*testing connection*/ if ($link_id) echo "Success in connecting!

"; else echo "Failed to connect.
";test

@mac,

yes MySQL is running....i'm running wamp.

here's the code for config.php:

Language: PHP
<?php define(';SQL_HOST';,';localhost';); define(';SQL_USER';,';lizwe';); define(';SQL_PASS';,';';); define(';SQL_DB';,';registration';); ?>

here's the include's code (server_connection.php):

Language: PHP
/*connecting to the server & database*/ $link_id = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS); mysql_select_db(SQL_DB); /*testing connection*/ if ($link_id) echo "Success in connecting! <br/><br/>"; else echo "Failed to connect.<br/>";

here's the code in the page with the includes:

Language: PHP
require (';includes/config.php';); require (';includes/server_connection.php';);

Plz yelp!

>>>
The One that owns The Technology rulez the world!
avatar
Mac
Re: includez
September 29, 2010 09:28PM
If that is what you are getting then it means the code is echoed and not parsed in server_connection.php, i.e. the server prints your code because you did not use <?php ?> tags , and it thus treats it as plain HTML. Silly mistake hey - but we all do it ad infinitum smiling smiley

Having said that, keep it simple by having ALL the connection code in config.php.

Language: PHP
<?php $dbhost = ';localhost';; $dbuser = ';liswe';; $dbpass =';';, $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (';Error connecting to mysql';);   $dbname = ';registration';; mysql_select_db($dbname); ?>

Then include config.php in all your pages. include(.......

Using DEFINE is a bit of an overkill here.

And you really should have a password.
Sorry, only registered users may post in this forum.

Click here to login