odd problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pgolovko
Forum Commoner
Posts: 38
Joined: Sun Sep 17, 2006 9:13 am

odd problem

Post by pgolovko »

I dont even know if its related to PHP or Apache ....

Code: Select all

$links_total = mysql_num_rows(mysql_query('SELECT `id` FROM `links`'));
The above code works and gives me the correct count from `links` table if I execute the file as http://server.com/index.php, yet it fails if I execute it as http://server.com/
The following code works in both cases:

Code: Select all

$pages_total = mysql_num_rows(mysql_query('SELECT `id` FROM `pages`'));
My ./htaccess file is:

Code: Select all

RewriteEngine on

RewriteRule ^(.*)/$ index.php?path=$1 [QSA,L]
RewriteRule ^/$ index.php [QSA,L]
RewriteRule ^(.*)/index([0-9]+).html$ index.php?path=$1&page=$2 [QSA,L]
RewriteRule ^index.html$ index.php [QSA,L]
I'm lost. Whats going on here? :?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

'Fail' is not a good description for your problem. Exactly what are you expecting? And what are you actually recieving?

(PS: the better query would be select count(id) from links.)
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

i suppose the problem is in your code outside of what you have shown here. can you paste the code for the page?
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

you need to look at "DirectoryIndex directive" of your httpd.conf file
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

itsmani1 wrote:you need to look at "DirectoryIndex directive" of your httpd.conf file
Agreed. This directive is controlled by what your Apache config file is told to do with file extensions presented as a Directory Index.
Post Reply