473,473 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

unexpected T_IF error

ok, I am totally new to php and come from an asp background.

I basically want to do an If > then > else > end if statement:
my page is:

<?php require_once('Connections/carresa.php'); ?>
<?php
$DateTime = date("Y/n/j");
$IP = $_SERVER["REMOTE_ADDR"];

mysql_select_db($database_carresa, $carresa);
$query_rs = "SELECT count(Hit_DateTime) as mycount FROM unique_ip WHERE
Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($query_rs, $carresa) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADDR"] . "<br>Date Time: " . $DateTime . "<br>Count: " .
$row_rs['mycount'] . "</span>"
//at this point I want to say IF row_rs['mycount']== 0 THEN PRINT WELCOME ON
THE PAGE
if ($row_rs['mycount']=='0'){
print "welcome";
}
?>
The page errors on line 17 which is the if line.

Any ideas ???

thanks
James Campbell
Jul 17 '05 #1
10 34681
"James Campbell" <ja***@stuttersystems.com> wrote:

print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADDR"] . "<br>Date Time: " . $DateTime . "<br>Count:
" . $row_rs['mycount'] . "</span>"
//at this point I want to say IF row_rs['mycount']== 0 THEN PRINT
WELCOME ON THE PAGE
if ($row_rs['mycount']=='0'){
print "welcome";
}
?>
The page errors on line 17 which is the if line.


You missed a semicolon in the "print" line before the if statement.

JOn
Jul 17 '05 #2
I noticed that Message-ID: <Xn**************************@130.133.1.4>
from Jon Kraft contained the following:
if ($row_rs['mycount']=='0'){
print "welcome";
}
?>
The page errors on line 17 which is the if line.


You missed a semicolon in the "print" line before the if statement.

Does it matter that the '0' is in single quotes?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
Geoff Berrow <bl******@ckdog.co.uk> wrote:
I noticed that Message-ID: <Xn**************************@130.133.1.4>
from Jon Kraft contained the following:
if ($row_rs['mycount']=='0'){
print "welcome";
}
?>
The page errors on line 17 which is the if line.
You missed a semicolon in the "print" line before the if statement.

Does it matter that the '0' is in single quotes?


Not really, it wouldn't throw an error for once and PHP's internal type
conversion would render that statement true if the number of rows returned
would be 0.
However, if ($row_rs['mycount']===0) would be the better solution.

JOn
Jul 17 '05 #4
Geoff, Jon,

Thanks for replying, I have tried both your suggestions, but still get the
error. My current code is:

if ($row_rs['mycount']===0){
print "welcome"
}

If I however put the code in like this:

<?php if ($row_rs['icount']=="0"){ ?>
<br>ddddd
<?php } ?>

The page works.

Any ideas ??

Thanks

James

"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:Xn**************************@130.133.1.4...
Geoff Berrow <bl******@ckdog.co.uk> wrote:
I noticed that Message-ID: <Xn**************************@130.133.1.4>
from Jon Kraft contained the following:
if ($row_rs['mycount']=='0'){
print "welcome";
}
?>
The page errors on line 17 which is the if line.

You missed a semicolon in the "print" line before the if statement.

Does it matter that the '0' is in single quotes?


Not really, it wouldn't throw an error for once and PHP's internal type
conversion would render that statement true if the number of rows returned
would be 0.
However, if ($row_rs['mycount']===0) would be the better solution.

JOn

Jul 17 '05 #5
"James Campbell" <ja***@stuttersystems.com> wrote:
Thanks for replying, I have tried both your suggestions, but still get
the error. My current code is:

if ($row_rs['mycount']===0){
print "welcome"
}

If I however put the code in like this:

<?php if ($row_rs['icount']=="0"){ ?>
<br>ddddd
<?php } ?>

The page works.

Any ideas ??


Hi James,

That doesn't make sense ... but you are using two different keys in your
example: 'mycount' and 'icount'. Could you post the complete code again?

JOn
Jul 17 '05 #6
I noticed that Message-ID:
<oQ******************@news-binary.blueyonder.co.uk> from James Campbell
contained the following:
if ($row_rs['mycount']===0){
print "welcome"
}


Have you tried
print "welcome";

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #7
Jon,

Sorry yes I saw that a few minutes ago (doh!)

The code that doesn't work is:

<?php require_once('Connections/carresa.php'); ?>
<?php
$DateTime = date("Y/n/j");
$IP = $_SERVER["REMOTE_ADDR"];

mysql_select_db($database_carresa, $carresa);
$query_rs = "SELECT count(Hit_DateTime) as mycount FROM unique_ip WHERE
Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($query_rs, $carresa) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADDR"] . "<br>Date Time: " . $DateTime . "<br>Count: " .
$row_rs['mycount'] . "</span>"
//at this point I want to say IF row_rs['mycount']== 0 THEN PRINT WELCOME ON
THE PAGE
if ($row_rs['mycount']===0){
print "welcome"
}
?>

The code that does work is:

<?php require_once('Connections/carresa.php'); ?>
<?php
$DateTime = date("Y/n/j");
$IP = $_SERVER["REMOTE_ADDR"];

mysql_select_db($database_carresa, $carresa);
$query_rs = "SELECT count(Hit_DateTime) as mycount FROM unique_ip WHERE
Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($query_rs, $carresa) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADDR"] . "<br>Date Time: " . $DateTime . "<br>Count: " .
$row_rs['mycount'] . "</span>"
//at this point I want to say IF row_rs['mycount']== 0 THEN PRINT WELCOME ON
THE PAGE
//if ($row_rs['mycount']===0){
//print "welcome"
//}
?>

<?php if ($row_rs['mycount']=="0"){ ?>
<br>ddddd
<?php } ?>
Seems strange how I can't include the bottom bit of code in the main chunk
of code ??

Cheers
James




"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:Xn**************************@130.133.1.4...
"James Campbell" <ja***@stuttersystems.com> wrote:
Thanks for replying, I have tried both your suggestions, but still get
the error. My current code is:

if ($row_rs['mycount']===0){
print "welcome"
}

If I however put the code in like this:

<?php if ($row_rs['icount']=="0"){ ?>
<br>ddddd
<?php } ?>

The page works.

Any ideas ??


Hi James,

That doesn't make sense ... but you are using two different keys in your
example: 'mycount' and 'icount'. Could you post the complete code again?

JOn

Jul 17 '05 #8
"James Campbell" <ja***@stuttersystems.com> wrote:
Jon,

Sorry yes I saw that a few minutes ago (doh!)

The code that doesn't work is:

<?php require_once('Connections/carresa.php'); ?>
<?php
$DateTime = date("Y/n/j");
$IP = $_SERVER["REMOTE_ADDR"];

mysql_select_db($database_carresa, $carresa);
$query_rs = "SELECT count(Hit_DateTime) as mycount FROM unique_ip
WHERE Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($query_rs, $carresa) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADDR"] . "<br>Date Time: " . $DateTime . "<br>Count:
" . $row_rs['mycount'] . "</span>"


Hi James,

Did you read my first post? :)

You missed a semicolon to end the above line!

JOn
Jul 17 '05 #9
Jon,

You are the man !!!!!

Excellent, thank you !

If you ever need and ASP code, just drop me an email.

Regards
James

"Jon Kraft" <jo*@jonux.co.uk> wrote in message
news:Xn**************************@130.133.1.4...
"James Campbell" <ja***@stuttersystems.com> wrote:
Jon,

Sorry yes I saw that a few minutes ago (doh!)

The code that doesn't work is:

<?php require_once('Connections/carresa.php'); ?>
<?php
$DateTime = date("Y/n/j");
$IP = $_SERVER["REMOTE_ADDR"];

mysql_select_db($database_carresa, $carresa);
$query_rs = "SELECT count(Hit_DateTime) as mycount FROM unique_ip
WHERE Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($query_rs, $carresa) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADDR"] . "<br>Date Time: " . $DateTime . "<br>Count:
" . $row_rs['mycount'] . "</span>"


Hi James,

Did you read my first post? :)

You missed a semicolon to end the above line!

JOn

Jul 17 '05 #10
James Campbell wrote:

ok, I am totally new to php and come from an asp background.

I basically want to do an If > then > else > end if statement:

my page is:

<?php require_once('Connections/carresa.php'); ?>
<?php
$DateTime = date("Y/n/j");
$IP = $_SERVER["REMOTE_ADDR"];

mysql_select_db($database_carresa, $carresa);
$query_rs = "SELECT count(Hit_DateTime) as mycount FROM unique_ip WHERE
Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($query_rs, $carresa) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);

print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADDR"] . "<br>Date Time: " . $DateTime . "<br>Count: " .
$row_rs['mycount'] . "</span>"

//at this point I want to say IF row_rs['mycount']== 0 THEN PRINT WELCOME ON
THE PAGE
if ($row_rs['mycount']=='0'){
print "welcome";
}
?>

The page errors on line 17 which is the if line.


Often, the error will be on the line prior to the one PHP reports. You didn't
end your print statement with a ";". The T_IF is unexpected because it
shouldn't be in the middle of a print statment.

Regards,
Shawn
--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: | last post by:
Some time ago I installed VC# 2003, made a small generic project, compile with the allow unsafe flag and I get the error below: "error CS1577: Assembly generation failed -- Unexpected exception...
3
by: Eric Anderson Vianet SAO | last post by:
hello all When i tried ´pg_dump -v -f dump.dmp dtbtransporte´ I got the error: pg_dump: restoring data for table tbdmovimento pg_dump: dumping out the contents of table tbdmovimento ...
5
by: Vijayakrishna Pondala | last post by:
Hi, We are using the following error randomly, when accessing a webservice method/servlet hosted on JBoss application server: The underlying connection was closed: An unexpected error occurred...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
8
by: Jim Michaels | last post by:
C:\prj\quiz\withusers>php tareports.php PHP Parse error: syntax error, unexpected T_ELSE in C:\prj\quiz\withusers\tareports.php on line 205 this is the section of code. if (isset($row4)) {...
11
by: MLH | last post by:
Private Sub ButtonP_Click() On Error GoTo Err_ButtonP_Click Dim ThisForm As String ThisForm = Me.Name Exit_ButtonP_Click: Exit Sub Err_ButtonP_Click: Dim r As String, k As String, Message3...
8
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine...
7
by: keley | last post by:
I am trying to use a script to send a list of items from a database. The code is listed below. I get an unexpected T_IF error on the second $mailer->Body line (line 55). If I comment out the 9...
5
praclarush
by: praclarush | last post by:
I've just started php, and this is a class assignment, but my question is I’m getting this error PHP Parse error: syntax error, unexpected T_IF, expecting T_VARIABLE or '$' in...
6
by: Ciaroscuro | last post by:
Howdy - In setting up a registration form, I'd like to keep any correct entries on the form (make them sticky). The Registration Form is "included" and has the the following structure: ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...

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.