Help with pulling data from database

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; // ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008
John
 
Posts: n/a
Default Help with pulling data from database

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.
Reply With Quote
  #2 (permalink)  
Old 04-18-2008
larry@portcommodore.com
 
Posts: n/a
Default Re: Help with pulling data from database


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.
Reply With Quote
  #3 (permalink)  
Old 04-18-2008
Sylvain SF
 
Posts: n/a
Default Re: Help with pulling data from database

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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:05 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0