View unanswered posts | View active topics It is currently Thu Dec 14, 2017 11:33 pm



Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
 Parse error: parse error, unexpected T_IF 
Author Message
Junior Member

Joined: Wed Dec 14, 2005 5:24 am
Posts: 7
Post Parse error: parse error, unexpected T_IF
Hi,

got a syntax problem with an image viewing script i'm trying to get working;


Parse error: parse error, unexpected T_IF on line 16

This is line 16;

if ($image = @getimagesize ('uploads/' . $_GET['image'])) {


Anybody any ideas? I'm stuck on this one, thanks.


Sat May 13, 2006 8:09 am
Report this post
Profile
Junior Member

Joined: Mon Apr 03, 2006 12:52 pm
Posts: 6
Post 
You'll need to post the preceeding lines since those are the ones most likely causing the problem.


Sun May 14, 2006 9:53 am
Report this post
Profile
Junior Member

Joined: Wed Dec 14, 2005 5:24 am
Posts: 7
Post 
Hi, heres the rest of the script:

<?php

//Set a variable for problem reporting
$okay= FALSE;

if (isset($_GET['image'])) {

//Get the extension of the image name
$text = substr ($_GET['image'], -4);

//Test if its a valid image extension
if ((strolower($ext) == '.jpg')
OR (strtolower($ext == 'jpeg') OR (strtolower($ext) == '.gif'))

//Get image info and display image
if ($image = @getimagesize ('uploads/' . $_GET['image'])) {
echo "<img src=\uploads/{$GET ['image']}\" $image[3] border="\2\" />";
$okay = TRUE;

}

}

}

if (!$okay) {
echo '<div align="center"><font color="red" size="+1">This script must recive a valid image name!</font></div>';

}
?>


<div align="center"><a href="javascript:self.close();">Close This Window</a></div>
</body>
</html>


Sun May 14, 2006 1:07 pm
Report this post
Profile
Junior Member

Joined: Sun May 14, 2006 3:18 pm
Posts: 1
Post 
Hi there
I think you need to finish the following line (line 13 i think) with a semi-colon ";"
OR (strtolower($ext == 'jpeg') OR (strtolower($ext) == '.gif'))

Not sure if that will do the trick or not?? let me know :D


Sun May 14, 2006 3:27 pm
Report this post
Profile
Junior Member

Joined: Mon Apr 03, 2006 12:52 pm
Posts: 6
Post 
You're missing a close parens:
if ((strolower($ext) == '.jpg')
OR (strtolower($ext) == 'jpeg') OR (strtolower($ext) == '.gif'))


Sun May 14, 2006 6:33 pm
Report this post
Profile
Junior Member

Joined: Sat May 20, 2006 10:02 am
Posts: 1
Location: UK
Post Parse error: parse error, unexpected T_IF
It looks like your script is expecting you to open curly braces after the long 'if' statement:

if ((strolower($ext) == '.jpg')
OR (strtolower($ext) == 'jpeg') OR (strtolower($ext) == '.gif'))
{
//do this
}


Sat May 20, 2006 10:13 am
Report this post
Profile WWW
Junior Member

Joined: Wed May 03, 2006 11:06 pm
Posts: 5
Post 
MARKAD,
Your also missing the dot in your jpeg extension.
//Test if its a valid image extension
if ((strolower($ext) == '.jpg')
OR (strtolower($ext) == [color=black]'.[/color]jpeg') OR (strtolower($ext) == '.gif'))

tav


Wed May 24, 2006 10:57 pm
Report this post
Profile
Junior Member

Joined: Tue Jun 27, 2006 7:32 am
Posts: 1
Post 
Ive got the same problem... (sorry for my bad english.. i am dutch...)

i am making a login system but it doesn't work.. i tried everything from the internet but nothing works..
so now i am busy to create something of myself..
I am not a minute busy and i come into a problem i can't solve.
so ik kept it simple..
the script:

<?php
ini_set('display_errors',1);
error_reporting(E_ALL &~E_NOTICE);
//connect en select de database
mysql_connect('db4.awardspace.com','MYDATABASE','MYPASSWORD');
mysql_select_db(DATABASE) or die( 'Unable to select database');
$username = $_POST["username"]
if(isset($POST['submit'])){
$sql = mysql_query("SELECT * FROM infragilisregister WHERE username='username'");
$result = mysql_num_rows($sql);
}

if($result=="0"){
echo "Deze account bestaat niet!";
exit;
} else {
print "Deze account bestaat";
echo "de gebruikersnaam is $username";
mysql_close();
}
} ?>

and in an other page i have a form with a submit button with the name="submit"

please help me.. there comes an error!!Image

it says that this: if(isset($POST['submit'])){ is wrong..
error = Parse error: parse error, unexpected T_IF and then the adres etc.

PLEASE HELP ME!!


Tue Jun 27, 2006 7:40 am
Report this post
Profile
Junior Member

Joined: Tue Jun 30, 2009 9:10 pm
Posts: 2
Post 
Hey guys I am having a similar Issues:
Parse error: syntax error, unexpected T_IF in ../includes/functions.php on line 78


function mysqli_prep( $value )
{
$magic_quotes_active = get_magic_quotes_gpc(); //Checks if magic quotes is active or not.
$new_enough_php = function_exists( "mysqli_real_escape_string"); // i.e PHP >= v 4.3.0

if ( $new_enough ) // PHP v4.3.0 of higher
{
if( $magic_quotes_active )
{ //Undoes the effects of magic quote if it is on so mysql_real_esacape_string can do it's job
$value = stripslashes( $value );
}
$value = mysqli_real_escape_string( $value );
}
else
( //before PHP v4.3.0 - if magic quotes aren't already on then add slashes manually
if( $magic_quotes_active == 0)
<--Line 78
{ //if magic quotes are active, then the slashes already exist
$value = addslashes( $value );
}
}
return $value;
}

I really don't see it.


Tue Jun 30, 2009 9:38 pm
Report this post
Profile
Junior Member

Joined: Tue Jun 30, 2009 9:10 pm
Posts: 2
Post 
Xnuiem wrote:
after the else, use a brace { not a para (

Using an IDE makes this type of error trouble shooting very easy.



Wow dude thank you, you don't know how long I looked at that code for haha.

I'm gonna try to see if that works when I get home. I appreciate the fast response! :)


___________________________________________

So I got home and it worked! I got another error but that was an easy fix. Thanks dude!!


Wed Jul 01, 2009 11:37 am
Report this post
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 16 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.