473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

php parse error, unexpected T_VARIABLE...

got this annoying error

I'm completly new to php... and i have no clue what is wrong here, from what i can tell there is nothing rong with this code... but that isn't what the borwser say :P

Parse error: parse error, unexpected T_VARIABLE in main.php on line 15

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title></title>
<head/>
<body style="background-color: transparent">
<?php
$file=fopen("news.txt","r") or exit("Unable to open file!");
$first = 1
$ordn = fgetc($file);
fgets($file);
while (!feof($file))
{
if $first = 1
{
$check = fgetc($file);
$first = 0
}
if $check = "_"
{
$check = fgetc($file);
}
if $check = $ordn
{
$ordn = $ordn - 1
while $check(!"_")
{
echo fgets($file);
$check = fgetc($file);
}
}
else
{
fgets($file);
$check = fgetc($file);
}
}
fclose($file);
?>
</body>
</html>

NEXT TIME ENCLOSE YOUR CODE WITHIN PHP, CODE OR HTML TAGS!! READ THE POSTING GUIDLINES BEFORE POSTING ANYTHING IN THIS FORUM! - Ronald :cool:
Nov 28 '06 #1
4 11611
got this annoying error

I'm completly new to php... and i have no clue what is wrong here, from what i can tell there is nothing rong with this code... but that isn't what the borwser say :P

Parse error: parse error, unexpected T_VARIABLE in main.php on line 15

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title></title>
<head/>
<body style="background-color: transparent">
<?php
$file=fopen("news.txt","r") or exit("Unable to open file!");
$first = 1
$ordn = fgetc($file);
fgets($file);
while (!feof($file))
{
if $first = 1
{
$check = fgetc($file);
$first = 0
}
if $check = "_"
{
$check = fgetc($file);
}
if $check = $ordn
{
$ordn = $ordn - 1
while $check(!"_")
{
echo fgets($file);
$check = fgetc($file);
}
}
else
{
fgets($file);
$check = fgetc($file);
}
}
fclose($file);
?>
</body>
</html>
Hi bovanshi,

You have missed the required semicolons and the ( ) in your if () statements. Your if statement conditions should be always inside ( ) .
Here , is the right code.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title></title>
<head/>
<body style="background-color: transparent">
<?php
$file=fopen("news.txt","r") or exit("Unable to open file!");
$first = 1;
$ordn = fgetc($file);
fgets($file);
while (!feof($file))
{
if ($first = 1)
{
$check = fgetc($file);
$first = 0;
}
if ($check = "_")
{
$check = fgetc($file);
}
if ($check = $ordn)
{
$ordn = $ordn - 1;
while ($check(!"_"))
{
echo fgets($file);
$check = fgetc($file);
}
}
else
{
fgets($file);
$check = fgetc($file);
}
}
fclose($file);

?>
</body>
</html>
This will work now.
YOU TOO SCRIPTEE!

NEXT TIME ENCLOSE YOUR CODE WITHIN PHP, CODE OR HTML TAGS!! READ THE POSTING GUIDLINES BEFORE POSTING ANYTHING IN THIS FORUM! - Ronald :cool:
Nov 28 '06 #2
Thank you xD
Nov 28 '06 #3
Thank you xD
You are welcome :)
Nov 29 '06 #4
i am getting similar parse error and i can't understand where exactly the sintax is wrong...can you help?
the code is
<?php
require_once('db_login.php');
$sdbh = "";
$expire = 900;
function sess_open($save_path, $session_name){
global $dbhost, $dbuser, $dbpasswd, $sdbh;
if (! $sdbh = mysql_pconnect($dbhost, $dbuser, $dbpasswd)){
echo mysql_error();
exit;
}
return true;
}
function sess_close(){
return true;
}
function sess_read($key){
global $sdbh, $dbname, $tb_sessions;
$query = "
select
data
from
$tb_sessions
where
id = '$key'
and
expire > UNIX_TIMESTAMP()
";
$result = mysql_query($query);
if($record = mysql_fetch_row($result)){
return $record;
}else {
print (mysql_error());

}
function sess_write($key, $val){
global $sdbh, $dbname, $tb_sessions, $expire;
$value = addslashes($val);
$query = "
replace into
$tb_sessions
values (
'$key',
'$value',
UNIX_TIMESTAMP() + $expire
)
";
$result = mysql_query($query);
echo mysql_error();
return $result;
}
function sess_destroy($key){
global $sdbh, $dbname, $tb_sessions;
$query = "
delete from
$tb_sessions
where
id = '$key'
";
$result = mysql_query($query);
return $result;
}
function sess_gc($maxlifetime){
global $sdbh, $dbname, $tb_sessions;
$query = "
delete from
$tb_sessions
where
expire < UNIX_TIMESTAMP()
";
$result = mysql_query($query);
return mysql_affected_rows($sdbh);
}
session_set_save_handler("sess_open","sess_close", "sess_read","sess_write","sess_destroy","sess_gc") ;
session_start();
$sn = session_name();
$sid = session_id();

?>
Feb 25 '07 #5

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

Similar topics

6
by: Ehartwig | last post by:
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After...
2
by: aamer | last post by:
can anyone please help me, im getting a dumb: Parse error: syntax error, unexpected T_VARIABLE in /home/jeddah/public_html/lomar/cart/remove.php on line 5 in the following file, <?php...
5
by: Anna MZ | last post by:
I am new to php and have written the following mysql code to enter the details of a new user in the admin subdomain of my website: $sql = "INSERT INTO 'users' ('userid', 'username', 'upassword')...
1
epots9
by: epots9 | last post by:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/xxx.php on line xxx I get that message when i try to run my...
1
by: mdouble | last post by:
I'm a complete novice with HTML and PHP. Recently I purchased an auto responder that requires me to edit a PHP file during the installation process as per directions provided in a read me file. ...
3
by: SilvaZodiac | last post by:
Hi everyone, I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the...
4
by: needhelp08 | last post by:
I am getting the error Parse error: syntax error, unexpected T_VARIABLE on line 4 but I can't seem to find what is wrong. Could someone please help. <?php $conn = @mysql_connect("localhost",...
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...
2
by: fburn | last post by:
I need some help with an error I'm getting using php 5.2.5 running on linux. I receive an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...

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.