Page 1 of 1

PHP Script not producing anthing plz help

Posted: Sat Mar 11, 2006 11:44 pm
by anticore
I'm working on a form handling script to add to a db. but the script yeilds nothing, not a simple echo or any error msgs. I'm not understanding why.
my forms uses this php script as the post action.

Code: Select all

<?
echo "The User Ride Has Been Posted.";

// Set Mysql Variables
$host="****";
$user="****";
$pass="****";
$db="****";
$tablename="*****";



// Connect to Mysql, select the correct database, and run teh query which adds the data gathered from 
//the form into the database

mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());

$add_all = "INSERT INTO $tablename (`name`, `year`, `yearcat`, `details`, `image1`, `image2`, `image3`,
 `image4`, `smpic`) VALUES ('$name', '$year', '$yearcat', '$details', '$image1', '$image2', 
'$image3', '$image4', '$smpic')",$db);
mysql_query($add_all) or die(mysql_error());
?>

Posted: Sun Mar 12, 2006 12:01 am
by feyd
Run the following in a new file and tell us the results please.

Code: Select all

<?php

$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
$rg = (in_array(strtolower(ini_get('register_globals')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$de = (in_array(strtolower(ini_get('display_errors')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$eol = (isset($_SERVER['HTTP_HOST']) ? "<br />\n" : "\n");

$ec = array(
	'E_STRICT' => 2048,
	'E_ALL' => 2047,
	'E_USER_NOTICE' => 1024,
	'E_USER_WARNING' => 512,
	'E_USER_ERROR' => 256,
	'E_COMPILE_WARNING' => 128,
	'E_COMPILE_ERROR' => 64,
	'E_CORE_WARNING' => 32,
	'E_CORE_ERROR' => 16,
	'E_NOTICE' => 8,
	'E_PARSE' => 4,
	'E_WARNING' => 2,
	'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
	if (($t & $v) == $v)
	{
		$e[] = $n;
		$t ^= $v;
	}
}
$er = $er . ' (' . implode(' | ', $e) . ')';

echo 'PHP Version: ' . $ve . $eol;
echo 'PHP OS: ' . $os . $eol;
echo 'Error Reporting: ' . $er . $eol;
echo 'Register Globals: ' . $rg . $eol;
echo 'Display Errors: ' . $de . $eol;

?>

Posted: Sun Mar 12, 2006 12:08 am
by anticore

Code: Select all

PHP Version: 5.0.5
PHP OS: Linux
Error Reporting: 2039 (E_USER_NOTICE | E_USER_WARNING | E_USER_ERROR | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_WARNING | E_ERROR)
Register Globals: On
Display Errors: Off

Posted: Sun Mar 12, 2006 12:11 am
by feyd
look in your php.ini.. see if short tags are off. (you can also look in phpinfo())

Posted: Sun Mar 12, 2006 12:17 am
by anticore
it says short_open_tags enabled :?:

Posted: Sun Mar 12, 2006 12:23 am
by feyd
does it also say that MySQL is installed?

Posted: Sun Mar 12, 2006 12:23 am
by anticore
yea its installed

Posted: Sun Mar 12, 2006 12:25 am
by feyd
add ini_set('display_errors',true) to the top of your file

Posted: Sun Mar 12, 2006 12:30 am
by anticore
nothing

the phpinfo() worked just fine, but this script wont echo a single thing...

Posted: Sun Mar 12, 2006 12:33 am
by feyd
that would suggest that you have a parse error, and looking at your code in more detail this is the line in error:

Code: Select all

$add_all = "INSERT INTO $tablename (`name`, `year`, `yearcat`, `details`, `image1`, `image2`, `image3`,
 `image4`, `smpic`) VALUES ('$name', '$year', '$yearcat', '$details', '$image1', '$image2', 
'$image3', '$image4', '$smpic')",$db);
remove the ,$db) from the end of that last line.

Posted: Sun Mar 12, 2006 1:52 pm
by anticore
Thats what it was, thanks for the help so much