Help With Pulling Data From Database

Help With Pulling Data From Database

am 18.04.2008 02:55:45 von John

I'm trying to get this page to work but need assistance.

-------------------------------
CODE--------------------------------------
$GLOBALS["FF_GLOBALS_VERBOSE"] = true; // For debugging purposes
include("database.php");

ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

$conn = mysql_connect("localhost", "jcweb##_test", "test") or
die(mysql_error());
mysql_select_db("jcweb06_test", $conn) or die(mysql_error());

$appt_date = $_POST['appt_month'] . '/' . $_POST['appt_day'] . '/' .
$_POST['appt_year'];
$phone = $_POST['phone1'] . '-' . $_POST['phone2'] . '-' .
$_POST['phone3'];
$appt_time = $_POST['appt_time'];


$query = "SELECT appt_date, appt_time FROM pest_control WHERE
appt_date = '$appt_date' and appt_time = '$appt_time'";


$result = mysql_query ($query);
if(mysql_num_rows($results) > 0)
{
echo "Success";
}
else
}
echo "No Records Returned";
}
?>
-----------------------------------------END
CODE-------------------------------------------------------- ------

When I do a print or echo of the variables I have set it does return
data so I think the problem is in my SQL statement. I have tried
everything I could think of but the page just returns blank and
doesn't print my message.

Any help is appreciated.

Re: Help With Pulling Data From Database

am 18.04.2008 03:20:42 von Jerry Stuckle

John wrote:
> I'm trying to get this page to work but need assistance.
>
> -------------------------------
> CODE--------------------------------------
> > $GLOBALS["FF_GLOBALS_VERBOSE"] = true; // For debugging purposes
> include("database.php");
>
> ini_set ('display_errors', 1);
> error_reporting (E_ALL & ~E_NOTICE);
>
> $conn = mysql_connect("localhost", "jcweb##_test", "test") or
> die(mysql_error());
> mysql_select_db("jcweb06_test", $conn) or die(mysql_error());
>
> $appt_date = $_POST['appt_month'] . '/' . $_POST['appt_day'] . '/' .
> $_POST['appt_year'];
> $phone = $_POST['phone1'] . '-' . $_POST['phone2'] . '-' .
> $_POST['phone3'];
> $appt_time = $_POST['appt_time'];
>
>
> $query = "SELECT appt_date, appt_time FROM pest_control WHERE
> appt_date = '$appt_date' and appt_time = '$appt_time'";
>
>
> $result = mysql_query ($query);
> if(mysql_num_rows($results) > 0)
> {
> echo "Success";
> }
> else
> } <=== This should be a LEFT brace.
> echo "No Records Returned";
> }
> ?>
> -----------------------------------------END
> CODE-------------------------------------------------------- ------
>
> When I do a print or echo of the variables I have set it does return
> data so I think the problem is in my SQL statement. I have tried
> everything I could think of but the page just returns blank and
> doesn't print my message.
>
> Any help is appreciated.
>

See comments above. This is why you should have your error settings in
the .ini file. Syntax errors mean nothing is ever executed, so you
won't get the errors displayed.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Help With Pulling Data From Database

am 18.04.2008 10:38:20 von luiheidsgoeroe

On Fri, 18 Apr 2008 02:55:45 +0200, John wrote:
> $result =3D mysql_query ($query);
> if(mysql_num_rows($results) > 0)

$result !=3D $results .....

> {
> echo "Success";
> }
> else
> }

As Jerry said. { instead of }
-- =

Rik Wasmus

Re: Help With Pulling Data From Database

am 20.04.2008 05:12:58 von John

On Apr 18, 1:38=A0am, "Rik Wasmus" wrote:
> On Fri, 18 Apr 2008 02:55:45 +0200, John wrote:
> > $result =3D mysql_query ($query);
> > if(mysql_num_rows($results) > 0)
>
> $result !=3D $results .....
>
> > {
> > =A0 =A0 echo "Success";
> > }
> > else
> > }
>
> As Jerry said. { instead of }
> --
> Rik Wasmus

Thank's Rik and Jerry, appreciate your help.

~John