|
-
Dec 5th, 2004, 12:07 PM
#1
Thread Starter
Hyperactive Member
php / mysql error Again
Ok this time the code below should query the db and flag if there are 2 records already in the db matching the time and date, yet it doesnt - however as before with my other problems it works fine on my test server so any clues any one
PHP Code:
$alarm_check = "SELECT atime, datetoplay FROM maintable WHERE atime = '" . $_POST['alarmtime'] . "' And datetoplay = '" . $_POST['datebox'] . "'"; // check if username exists in database.
if (!($alarm_check)) print mysql_error();
$result1 = mysql_query($alarm_check);
$num_row = mysql_num_rows($result1);
if ($num_row == 2)
{
die('<p align="center"><strong><font face="Century Gothic">Im sorry but this time slot is full.</font></strong></p><p align="center"><font face="Century Gothic"><a href="newentry.php">Please go back and pick another time</a></font></p><p align="center"><a href="index.html"><img src="images/smallhouse.gif" alt="Home" width="53" height="67" border="0"></a></p>');
//die ($num_row);
}
many thanks chrisio
Last edited by Chrisio; Dec 5th, 2004 at 12:52 PM.
Reason: resolved
-
Dec 5th, 2004, 12:24 PM
#2
Re: php / mysql error Again
So what error are you getting?
-
Dec 5th, 2004, 12:29 PM
#3
Thread Starter
Hyperactive Member
Re: php / mysql error Again
Thats just it im not getting any it just posts it to the db and shows the page as though there were less than 2 entrys
-
Dec 5th, 2004, 12:40 PM
#4
Re: php / mysql error Again
Your server configurations may be different. I suspect that an error is occuring in your query. It would help to chekc the query result rather than the query text after you have called mysql_query(). Change your code to this to see if you get an error dispalyed.
PHP Code:
error_reporting(E_ALL);
$alarm_check = "SELECT atime, datetoplay FROM maintable WHERE atime = '" . $_POST['alarmtime'] . "' And datetoplay = '" . $_POST['datebox'] . "'"; // check if username exists in database.
if (! ($result1 = mysql_query($alarm_check))) {
die(mysql_error());
}
$num_row = mysql_num_rows($result1);
if ($num_row == 2) {
die('<p align="center">
<strong><font face="Century Gothic">Im sorry but this time slot is full.</font></strong>
</p><p align="center"><font face="Century Gothic"><a href="newentry.php">Please go back and pick another time</a></font></p>
<p align="center"><a href="index.html"><img src="images/smallhouse.gif" alt="Home" width="53" height="67" border="0"></a>
</p>');
}
-
Dec 5th, 2004, 12:52 PM
#5
Thread Starter
Hyperactive Member
Re: php / mysql error Again
thanks very much all it required was some one with a bit off knowledge and I found it in a missspelled variable
it was relating to the sql query
thanks again
chrisio
-
Dec 5th, 2004, 01:01 PM
#6
Re: php / mysql error Again
Its always a good idea to set error reporting to E_ALL while developing. The display of notices when you misspell variables is a god send and without it you can get some very strange and confusing errors.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|