Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
monkeymafia
Forum Commoner
Posts: 31 Joined: Mon Oct 08, 2007 3:08 pm
Post
by monkeymafia » Thu Nov 29, 2007 6:43 am
hi all
trying to execute a query and display items that have been updated within the past week. am pretty sure the query itself is correct but its throwing the following error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/kumar/public_html/Storm Broadband/datequery1.php on line 10
here is all the code:
Code: Select all
<?php
include 'dbconnect.php';
$result = mysql_query('SELECT * FROM technicalproblems
WHERE updated > DATE_SUB(NOW(), INTERVAL 1 WEEK)
ORDER BY created DESC');
print "<h1>Items updated within past week</h1>\n";
if (mysql_num_rows($result)) {
print "<TABLE BORDER=\"1\"><TR STYLE=\"font-weight: bold;\"><TD>MemberID</TD><TD>First Name</TD><TD>Surname</TD><TD>Package</TD></TR>";
while($row = mysql_fetch_assoc($result)) {
extract($row);
print "<TR><TD>$updated</TD><TD>$created</TD><TD>$fk_memberid2</TD><TD>$subject</TD></TR>";
}
print "</TABLE>";
}
?>
not to sure whats going wrong. any ideas? thanks for any help
Zoxive
Forum Regular
Posts: 974 Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan
Post
by Zoxive » Thu Nov 29, 2007 7:50 am
Code: Select all
if(!$result)
die('Query Failed...<br>' . mysql_error());
monkeymafia
Forum Commoner
Posts: 31 Joined: Mon Oct 08, 2007 3:08 pm
Post
by monkeymafia » Thu Nov 29, 2007 8:08 am
thanks for the reply. its stating that theres a problem with the actual query:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WEEK)' at line 2
Not too sure whats wrong with the query though?
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Thu Nov 29, 2007 8:34 am
The values QUARTER and WEEK are available beginning with MySQL 5.0.0.
There are 10 types of people in this world, those who understand binary and those who don't
monkeymafia
Forum Commoner
Posts: 31 Joined: Mon Oct 08, 2007 3:08 pm
Post
by monkeymafia » Thu Nov 29, 2007 8:37 am
arghh!
so is there no way to execute a similiar query using version 4?
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Thu Nov 29, 2007 9:02 am
1 week = ? days
There are 10 types of people in this world, those who understand binary and those who don't
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Thu Nov 29, 2007 9:10 am
Also, you may find
YEARWEEK() useful.
There are 10 types of people in this world, those who understand binary and those who don't
monkeymafia
Forum Commoner
Posts: 31 Joined: Mon Oct 08, 2007 3:08 pm
Post
by monkeymafia » Sat Dec 01, 2007 8:55 am
thanks for the replies.