|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Apr 2009
Posts: 567
|
undefined variables $PHP_SELF help!
i am modifying a script that catches how many users are online in that corrent web page.
Well I am getting this three errors the script i am using is below the error messages can anyone tell me how can i defined this variables, I am using PHP 5 in case these variables has changed or didn't exist in former PHP versions Quote:
PHP Script: PHP Code:
|
|
|
|
|
|
|
#2 |
|
¬.¬ shoooo...
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Oct 2005
Location: CA
Posts: 6,943
|
Gah....Sitepoint it putting it all lower case
![]() Code:
$_server['remote_addr'] $_server['php_self'] |
|
|
|
|
|
#3 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Oct 2005
Posts: 975
|
i think u r missing whole part of tutorials ...i have not seen tutorials but may be that tutorial might have said to initilize those two CONSTANT somewhere in passage form which u missed....
REMOTE_ADDR constant itself doesnt have any special meaning unless used with some SUPER varibales like $_SERVER so me be DEFINE ('REMOTE_ADDR', $_server['remote_addr']); DEFINE ('PHP_SELF', $_server['php_self']); will help |
|
|
|
|
|
#4 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Dec 2005
Posts: 661
|
$PHP_SELF doesnt many any sense, unless you do the following:
PHP Code:
Thanks |
|
|
|
|
|
#5 |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Apr 2009
Posts: 567
|
I have the variables defined as you guys has given me and I have place into the code, But there is a parse error in line 65
PHP Code:
|
|
|
|
|
|
#6 | |||
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Apr 2009
Posts: 567
|
guys I fixed it already thank you!!
Code:
file='{$_server['php_self']}'"
I have the header.php script included in index.php. Header.php contain the whole script we have been working here which is header.php PHP Code:
Quote:
PHP Code:
Quote:
But i as put in the quote above Quote:
|
|||
|
|
|
|
|
#7 | |
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Apr 2009
Posts: 567
|
Thank you I got that the Global Variables can not be lower cases thank you.. Need to learn more about parsing do you know of a good tutorial about parsing...
Because the curly braces did the job here.. One more thing is not inserting why? Quote:
the final draft come to this PHP Code:
This is the insertion point: PHP Code:
Now one of the things I have is that I open an connection in header.php Code:
//fill in some basic info $server = "localhost"; $db_user = "username"; $db_pass = "password"; $database = "users"; $timeoutseconds = 300; Index.php has a connection to the same database as well so now we have two connection I know it is unnecessary having two connection but because of my lack of ability to adapt the tutorial connection to the one i have already i haven't done it. $timeoutseconds = 300; variable and it's numeric value has terrified me to try.. Well I have tried doing this. Index.php PHP Code:
The connection.php looks like this. PHP Code:
Still the connection is failing I don't know what could be the cause... |
|
|
|
|
|
|
#8 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Oct 2005
Posts: 975
|
ok i am not sure why r u hard coding all things in header.php and again making file called connection
better make connection file and then may be include connection in header may be connection like this Code:
DEFINE ('DB_USER', 'username');
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'dbname');
if ($dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // Make the connnection.
if (!mysql_select_db (DB_NAME)) { // If it can't select the database.
// Handle the error.
error_handler (mysql_errno(), 'Could not select the database: ' . mysql_error());
//just echo message
exit();
} // End of mysql_select_db IF.
} else { // If it couldn't connect to MySQL.
error_handler (mysql_errno(), 'Could not connect to the database: ' . mysql_error());
exit();
} // End of $dbc IF.
|
|
|
|
|
|
#9 | |||
|
SitePoint Evangelist
![]() ![]() ![]() ![]() Join Date: Apr 2009
Posts: 567
|
I am just working with header.php
When i open header.php alone which is below it will still display the same errors... Uch.... Your connection set up you have done in your last post is included here but still it display Quote:
PHP Code:
http://www.spoono.com/php/tutorials/tutorial.php?id=16 the sql database as in the tutorial is as below Quote:
KEY ip (ip) KEY file (file) but the actual database dump I have in phpmyadmin is as: Quote:
KEY ip (ip) KEY file (file) That could be one of the issues. [/quote] |
|||
|
|
|
|
|
#10 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Oct 2005
Posts: 975
|
ok i have found that tutorial use much old function
rather try this http://www.phpeasystep.com/phptu/9.html i have tested this once and i worked at that time and may be work now as well |
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 03:26.










Linear Mode
