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
anticore
Forum Newbie
Posts: 21 Joined: Sat Mar 11, 2006 11:37 pm
Post
by anticore » Sat Mar 11, 2006 11:44 pm
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());
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Mar 12, 2006 12:01 am
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;
?>
anticore
Forum Newbie
Posts: 21 Joined: Sat Mar 11, 2006 11:37 pm
Post
by anticore » Sun Mar 12, 2006 12:08 am
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Mar 12, 2006 12:11 am
look in your php.ini.. see if short tags are off. (you can also look in
phpinfo() )
anticore
Forum Newbie
Posts: 21 Joined: Sat Mar 11, 2006 11:37 pm
Post
by anticore » Sun Mar 12, 2006 12:17 am
it says short_open_tags enabled
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Mar 12, 2006 12:23 am
does it also say that MySQL is installed?
anticore
Forum Newbie
Posts: 21 Joined: Sat Mar 11, 2006 11:37 pm
Post
by anticore » Sun Mar 12, 2006 12:23 am
yea its installed
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Mar 12, 2006 12:25 am
anticore
Forum Newbie
Posts: 21 Joined: Sat Mar 11, 2006 11:37 pm
Post
by anticore » Sun Mar 12, 2006 12:30 am
nothing
the phpinfo() worked just fine, but this script wont echo a single thing...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Mar 12, 2006 12:33 am
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.
anticore
Forum Newbie
Posts: 21 Joined: Sat Mar 11, 2006 11:37 pm
Post
by anticore » Sun Mar 12, 2006 1:52 pm
Thats what it was, thanks for the help so much