473,569 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting parse errors with these small bit of codes

155 New Member
I'm getting - parse error, unexpected T_LNUMBER - error messages referring to the last "if" lines of this code.

What I'm trying to do is check the database and if this user's article row isn't empty AND the article that's in there isn't older than 90 days then execute the "if" clause. I've tried it two different ways and neither of them work. The trouble must be with this since it is in both ways that I've tried:
[PHP]$posted > SUBDATE(NOW(), INTERVAL 90 DAY)[/PHP]

The first way:
[PHP]if (isset($_SESSIO N['user_id']))
{

$query = "SELECT article, posted, FROM articles where user_id='".$_SE SSION['user_id']."'";
$result = mysql_query($qu ery);
while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
$article = stripslashes($r ow['article']);
$posted = $row['posted'];
}
if ($article != '' && $posted > SUBDATE(NOW(), INTERVAL 90 DAY))
{[/PHP]

Other way:
[PHP]$query = "SELECT article, posted, FROM articles where user_id='".$_SE SSION['user_id']."'";
$result = mysql_query($qu ery);
while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
$article = stripslashes($r ow['article']);
$posted = $row['posted'];
}
if ($article == '')
{
echo "";
}
elseif ($posted < SUBDATE(NOW(), INTERVAL 90 DAY))
{
echo "";
}
else
{[/PHP]
Oct 14 '07 #1
2 1250
DavidPr
155 New Member
I also tried this, but received the same error message concerning line #10 below:[PHP]$query = "SELECT article, posted, FROM articles where user_id='".$_SE SSION['user_id']."'";
$result = mysql_query($qu ery);
while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
$article = stripslashes($r ow['article']);
$posted = $row['posted'];
}
if ($article != '')
{
if ($posted > SUBDATE(NOW(), INTERVAL 90 DAY))
{

echo "

<!-- Form Goes Here -->

";
}
}
else
{
echo "";
}[/PHP]
Oct 14 '07 #2
pbmods
5,821 Recognized Expert Expert
Heya, David.

Expand|Select|Wrap|Line Numbers
  1. SUBDATE(NOW(), INTERVAL 90 DAY)
is SQL, not PHP.

Instead you'll want to do this:
Expand|Select|Wrap|Line Numbers
  1. time() - 7776000
  2.  
(there are 7,776,000 seconds in 90 days)
Oct 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
2124
by: Alejandro Forero Cuervo | last post by:
Hello. I'm new to PostgreSQL and I'm using it for some project. I am currently creating an entity engine that provides a web interface, which is oriented towards end users, to the database based on some enriched description of the tables (from which it also generates the SQL code to create them). My application ...
15
1609
by: Walter Dnes (delete the 'z' to get my real address | last post by:
A long time ago, in a place far away, there was an OS called DOS that had standard numeric return codes. Regardless of the programming language used, the same error return codes were supposed to be used. See http://www.felgall.com/doserr.htm for a larger list. It starts like so... # 1 Invalid Function Code # 2 File Not Found # 3 Path...
19
3205
by: Johnny Google | last post by:
Here is an example of the type of data from a file I will have: Apple,4322,3435,4653,6543,4652 Banana,6934,5423,6753,6531 Carrot,3454,4534,3434,1111,9120,5453 Cheese,4411,5522,6622,6641 The first position is the info (the product) I want to retreive for the corresponding code. Assuming that the codes are unique for each product and all...
10
1623
by: yawnmoth | last post by:
I have two servers that have had PHP installed on them and... <?php echo 'hello, world! ?> ....displays a parse error on server A and doesn't display anything on server B. Any ideas as to what the problem is?
10
3186
by: Michael B. Trausch | last post by:
Alright... I am attempting to find a way to parse ANSI text from a telnet application. However, I am experiencing a bit of trouble. What I want to do is have all ANSI sequences _removed_ from the output, save for those that manage color codes or text presentation (in short, the ones that are ESChttp://fd0man.theunixplace.com/Tmud.tar which...
3
1958
by: starke1120 | last post by:
I have a table (tblVAS) that contains a field called VAS (Value Added Servies). This field is imported from an AS/400 and the filed contains several codes that relate to Value Added Services. The problem is that they are not ALWAYS seperated with a space, but sometimes are. I am in need of query the field and matching up the codes to the...
1
64043
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts,...
2
6644
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double) Location: class Week5MortgageGUI Week5MortgageLogic allint = logic.allInterest(amount, term, rate); Week5MortgageGUI.java:152:cannot find symbol...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.