473,575 Members | 3,439 Online
Bytes | Software Development & Data Engineering Community
+ 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('C onnections/carresa.php'); ?>
<?php
$DateTime = date("Y/n/j");
$IP = $_SERVER["REMOTE_ADD R"];

mysql_select_db ($database_carr esa, $carresa);
$query_rs = "SELECT count(Hit_DateT ime) as mycount FROM unique_ip WHERE
Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($qu ery_rs, $carresa) or die(mysql_error ());
$row_rs = mysql_fetch_ass oc($rs);
$totalRows_rs = mysql_num_rows( $rs);
print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADD R"] . "<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 34690
"James Campbell" <ja***@stutters ystems.com> wrote:

print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADD R"] . "<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.u k> 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***@stutters ystems.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.blueyond er.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('C onnections/carresa.php'); ?>
<?php
$DateTime = date("Y/n/j");
$IP = $_SERVER["REMOTE_ADD R"];

mysql_select_db ($database_carr esa, $carresa);
$query_rs = "SELECT count(Hit_DateT ime) as mycount FROM unique_ip WHERE
Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($qu ery_rs, $carresa) or die(mysql_error ());
$row_rs = mysql_fetch_ass oc($rs);
$totalRows_rs = mysql_num_rows( $rs);
print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADD R"] . "<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('C onnections/carresa.php'); ?>
<?php
$DateTime = date("Y/n/j");
$IP = $_SERVER["REMOTE_ADD R"];

mysql_select_db ($database_carr esa, $carresa);
$query_rs = "SELECT count(Hit_DateT ime) as mycount FROM unique_ip WHERE
Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($qu ery_rs, $carresa) or die(mysql_error ());
$row_rs = mysql_fetch_ass oc($rs);
$totalRows_rs = mysql_num_rows( $rs);
print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADD R"] . "<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.u k> wrote in message
news:Xn******** *************** ***@130.133.1.4 ...
"James Campbell" <ja***@stutters ystems.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***@stutters ystems.com> wrote:
Jon,

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

The code that doesn't work is:

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

mysql_select_db ($database_carr esa, $carresa);
$query_rs = "SELECT count(Hit_DateT ime) as mycount FROM unique_ip
WHERE Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($qu ery_rs, $carresa) or die(mysql_error ());
$row_rs = mysql_fetch_ass oc($rs);
$totalRows_rs = mysql_num_rows( $rs);
print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADD R"] . "<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.u k> wrote in message
news:Xn******** *************** ***@130.133.1.4 ...
"James Campbell" <ja***@stutters ystems.com> wrote:
Jon,

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

The code that doesn't work is:

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

mysql_select_db ($database_carr esa, $carresa);
$query_rs = "SELECT count(Hit_DateT ime) as mycount FROM unique_ip
WHERE Hit_IP = '$IP' and hit_datetime = '#$DateTime#'";
$rs = mysql_query($qu ery_rs, $carresa) or die(mysql_error ());
$row_rs = mysql_fetch_ass oc($rs);
$totalRows_rs = mysql_num_rows( $rs);
print "<span class=white11>" . $query_rs . "<br>IP: " .
$_SERVER["REMOTE_ADD R"] . "<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

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

Similar topics

4
5963
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 processing attribute -- System.ArgumentException: Invalid directory on URL." (If I do not compile with the unsafe flag compiler setting all compiles...
3
7382
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 pg_dump: ERROR: unexpected chunk number 8 (expected 0) for toast value 6935693
5
24742
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 on a receive. We are using .NET v1.1.
5
4489
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 including the -q64 option in xlC compiler. And we are able to link all these libraries to one of the main applications and generate an executable....
8
2809
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)) { if (isset($row5)) { //answer given? if ($row4==$row5) {
11
4202
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 As String
8
46174
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 where the inital " started? I find myself adding /* */ blocks or cutting/pasting sections of code out in order to find where the error occured. ...
7
1389
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 $mailer->Body lines with php code (55-62 and 64), the script works correctly. I am relatively new to coding, so I am sure I have left something out, I...
5
10018
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 C:\wamp\www\ssp\SSP04\guessingGame.php on line 42. I’ve tried to make sense of it but I’m at a lose, there error is referring to this segment of the code. else{...
6
5357
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: <body> <?php echo " <p>
0
7845
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8120
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
8281
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...
1
7868
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6515
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...
1
5664
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5338
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...
1
1382
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1107
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.