This is a discussion on Help with pulling data from database within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I'm trying to get this page to work but need assistance. ------------------------------- CODE-------------------------------------- <?php $GLOBALS["FF_GLOBALS_VERBOSE"] = true; // ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm trying to get this page to work but need assistance.
------------------------------- CODE-------------------------------------- <?php $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. |
|
|||
|
I would start by doing an echo of $query first to see what you are submitting to MySQL. If it looks OK and you have access to PHPMyAdmin, you might run the query output through that and see what PHPMyAdmin locates. I usually tweak my failing complex queries through there to debug the query. |
|
|||
|
John wrote on 18/04/2008 03:45:
> I'm trying to get this page to work but need assistance. > > $appt_date = $_POST['appt_month'] . '/' . $_POST['appt_day'] . '/' . > $_POST['appt_year']; I use to format date as 'yyyy-mm-dd' not 'yyyy/mm/dd' I don't know if it that important or depending of a locale. > $query = "SELECT appt_date, appt_time FROM pest_control WHERE > appt_date = '$appt_date' and appt_time = '$appt_time'"; > $result = mysql_query ($query); here a "or die(mysql_error()) will be useful. Sylvain. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|