PHP script adding a slash at the end of url?

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
implications
Forum Commoner
Posts: 25
Joined: Thu Apr 07, 2011 3:59 am

PHP script adding a slash at the end of url?

Post by implications »

I have created an install.php file that creates a table in a MySQL database and it's adding a slash to the add of the URL for some reason. So it looks like install.php/

This doesn't happen on the other pages. I tried creating a random file called random.php and there was no slash added to the end so it doesn't seem to be a domain issue.

The code on the install.php file is as follows:

Code: Select all

<?php
define('SHIELD', true);
require('settings.php');

$sql = "SELECT * FROM $db_table";
$result = @mysql_query($sql);
if ($result) {
	exit('This script has already been installed. Please delete <b>install.php</b> from the directory for security reasons.');
} else {

$create = ("CREATE TABLE IF NOT EXISTS `".$db_table."` (
	  `id` int(4) NOT NULL auto_increment,
	  `question` text NOT NULL,
	  `answer` text NOT NULL,
	  `dateasked` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
	  `ip` varchar(20) NOT NULL default '',
	  PRIMARY KEY  (`id`)
		) TYPE=MyISAM AUTO_INCREMENT=1 ;");
		
if (mysql_query($create, $connect)) {
   echo 'The script has been successfully installed. <a href="admin.php">Click here to proceed to the admin panel.</a>';
} else {
   die("Error: ". mysql_error());
}
}
?>
Is there something in there that is somehow creating the slash at the end?
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: PHP script adding a slash at the end of url?

Post by Eric! »

Are you saying you think $db_table="index.php" then the SELECT fails and it creates a table "index.php/"?

Have you really looked at the results of var_dump($db_table) to see what is there? Without seeing how you define it, it is hard to guess at your problem.
Post Reply