ok, something more explanatory.
If your script stops somewhere and you can't figure why and where try to trace to where the script is running.
e.g.
Code: Select all
<?php ...
echo 'checking $cat, value is: ', $cat, '<br />'; // debug, remove me
if ($cat <> "")
{ ...
?>Although echo/printf-debugging is effective for small/medium projects it's ugly and can lead to unexpected behaviours (if you forget to remove all of the statements for example).
When your projects become more complex you should consider installing a real debugger (see: http://php.net/debugger)
Another way is to use assertions (http://www.php.net/manual/en/function.assert.php)
(btw: looking into your code I found you've placed error_reporting() and ini_set() at the wrong place)
ok, let's take (a part of) the basic structure of your script
Code: Select all
<?php
error_reporting(TRUE);
ini_set('display_errors', TRUE);
require_once('Connections/cds.php');
?>
<?php
$db_connection = mysql_connect($hostname_cds , $username_cds , $password_cds) or die ("Could not connect to database");
...
if ($s == "pw")
{
...
}
if ($s == "cd")
{
if (($title <> "")||($company <> ""))
{
}
if ($disc <> "")
{
}
if ($cat <> "")
{
}
}
?>If there's something else in the script there have to be other assertions. But I'm sure you'll get the point
At the top-level your script takes different actions on the value of $s, valid values are pw and cd. You might write
Code: Select all
<?php ...
if ($s == "pw")
{ ... }
elseif($s == "cd")
{ ... }
else
{ echo 'malformed request'; }
... ?>If the script shall do anything there must be a variable $s and its value must be either pw or cd
Code: Select all
assert('isset($s) && ($s=="pw" || $s=="cd")');Code: Select all
<?php ...
if (($title <> "")||($company <> ""))
{ ... }
elseif ($disc <> "")
{ ... }
elseif ($cat <> "")
{ ... }
else
echo 'malformed request for s=cd';
... ?>Code: Select all
assert('!empty($title) || !empty($company) || !empty($disc) || !empty($cat)')Code: Select all
<?php
error_reporting(TRUE);
ini_set('display_errors', TRUE);
assert_options (ASSERT_ACTIVE, 1);
assert_options (ASSERT_WARNING, 1);
require_once('Connections/cds.php');
?>
<?php
$db_connection = mysql_connect($hostname_cds , $username_cds , $password_cds) or die ("Could not connect to database");
...
assert('isset($s) && ($s=="pw" || $s=="cd")');
if ($s == "pw")
{
...
}
elseif ($s == "cd")
{
assert('!empty($title) || !empty($company) || !empty($disc) || !empty($cat)');
if (($title <> "")||($company <> ""))
{ ... }
elseif ($disc <> "")
{ ... }
elseif ($cat <> "")
{ ... }
else
echo 'malformed request for s=cd';
}
else
'echo malformed request, parameter s is missing';
?>p.s.: no code-snippet is tested