/    Sign up×
Community /Pin to ProfileBookmark

error on ?>

Hey im getting a small error on my php script and im not sure why

the error is Parse error: parse error, unexpected $end in on line 46 which is the line ?> at the very end.

Thanks adam

[code=php]
<?PHP
require_once(‘page_build.php’);

//conn
$conn = mysql_connect(“localhost”, “k0m0d0”, “ragnarok”) or die(mysql_error());

//select db
mysql_select_db(“ebay”,$conn) or die(mysql_error());

//statement
$sql = “SELECT AuctionID, WinnerUserID FROM itemswon WHERE WinnerUserID =
‘$_POST[eBayUserID]’ AND eBayItemNumber = ‘$_POST[eBayItemNumber]'”;

//if script
$result = mysql_query($sql, $conn) or die(mysql_error());
if (mysql_num_rows($result) ==1) {

//fetch results
$row = mysql_fetch_array($result);

//extract is into the echo
extract($row);

//new sql statement
$sql2 = “SELECT Title, SubTitle FROM auctions WHERE ID = ‘$AuctionID'”;

//run the query
$result2 = mysql_query($sql2, $conn) or die(mysql_error());
if (mysql_num_rows($result2) ==1) {

//fetch results
$row2 = mysql_fetch_array($result2);

//extract is into the echo
extract($row2);

//display HTML from the page_build
page_header();
ebay_2();
page_footer();

// If the eBayItemNumber dont exist
} else {
echo “Your eBayUserID”;
};
?>
[/code]

Thanks Adam

to post a comment
PHP

16 Comments(s)

Copy linkTweet thisAlerts:
@physicforAug 13.2004 — in the name of allah

my dear

i think that

you forget to close the first if so you have to put } at the end of th first if statment

yours mohamed ali
Copy linkTweet thisAlerts:
@k0r54authorAug 13.2004 — Thanks but where sorry?
Copy linkTweet thisAlerts:
@NogDogAug 13.2004 — Could it be the unnecessary semi-colon at the end of the last line before the "?>" ?
Copy linkTweet thisAlerts:
@physicforAug 13.2004 — OH !!!

HOW DID YOU DID IT
Copy linkTweet thisAlerts:
@k0r54authorAug 13.2004 — nope its still happening sorry any idea's
Copy linkTweet thisAlerts:
@solavarAug 13.2004 — Here:

[code=php]

if (mysql_num_rows($result) ==1) { //THIS IS AN OPENING BRACE. WHERE iS THE CLOSING ONE?

//fetch results
$row = mysql_fetch_array($result);

//extract is into the echo
extract($row);

//new sql statement
$sql2 = "SELECT Title, SubTitle FROM auctions WHERE ID = '$AuctionID'";

//run the query
$result2 = mysql_query($sql2, $conn) or die(mysql_error());
if (mysql_num_rows($result2) ==1) { // HERE IS ANOTHER OPENING BRACE. THE LAST ONE WAS NOT CLOSED

[/code]
Copy linkTweet thisAlerts:
@k0r54authorAug 13.2004 — ok i have put another one at the end i didn't c that thanks

like this

[code=php]
echo "Your eBayUserID";
};
};
?>
[/code]


but its now returning a blank page i have taken out the function and put in an echo to test

[code=php]
//page_header();
//ebay_2();
//page_footer();
echo "well done";
[/code]


but its still happening.

Thanks Adam
Copy linkTweet thisAlerts:
@solavarAug 13.2004 — No, it is not just a matter of putting a brace wherever you want.

It's got to make sense.

In fact, it doesn't belong at the end. It belongs at the point just before the next if statement.

Here:

[code=php]

if (mysql_num_rows($result) ==1) {

//fetch results
$row = mysql_fetch_array($result);

//extract is into the echo
extract($row);


/* If the first IF statement is DONE, then it must be closed off, right here, with a brace */

} /* The only way it can not go here is if the second IF is NESTED in the first.
Does the second IF depend on the FIRST, then the brace will appear elsewhere */






//new sql statement
$sql2 = "SELECT Title, SubTitle FROM auctions WHERE ID = '$AuctionID'";

//run the query

$result2 = mysql_query($sql2, $conn) or die(mysql_error());
if (mysql_num_rows($result2) ==1) {

[/code]
Copy linkTweet thisAlerts:
@k0r54authorAug 13.2004 — Hi, thats the thing is, it is nested in the first one so the brace does need to go at the end.

but it still aitn working i have tried putting it in loadz of places.

Thanks Adam
Copy linkTweet thisAlerts:
@NogDogAug 13.2004 — Indenting always helps, too. Here is your original with consistent indention sytle:
[code=php]
<?PHP
require_once('page_build.php');
//conn
$conn = mysql_connect("localhost", "k0m0d0", "ragnarok") or die(mysql_error());
//select db
mysql_select_db("ebay",$conn) or die(mysql_error());
//statement
$sql = "SELECT AuctionID, WinnerUserID FROM itemswon WHERE WinnerUserID =
'$_POST[eBayUserID]' AND eBayItemNumber = '$_POST[eBayItemNumber]'";
//if script
$result = mysql_query($sql, $conn) or die(mysql_error());
if (mysql_num_rows($result) ==1)
{
//fetch results
$row = mysql_fetch_array($result);
//extract is into the echo
extract($row);
//new sql statement
$sql2 = "SELECT Title, SubTitle FROM auctions WHERE ID = '$AuctionID'";
//run the query
$result2 = mysql_query($sql2, $conn) or die(mysql_error());
if (mysql_num_rows($result2) ==1)
{
//fetch results
$row2 = mysql_fetch_array($result2);
//extract is into the echo
extract($row2);
//display HTML from the page_build
page_header();
ebay_2();
page_footer();
// If the eBayItemNumber dont exist
}
else
{
echo "Your eBayUserID";
}; // <<-- NogDog's comment: why is this semi-colon here?
?>
[/code]

You see how the if's and else's do not balance out? Without being sure what your actually desired logic is, I'm not sure where you need the extra braces, etc. Also, there is no purpose served by the ";" after the last "}".
Copy linkTweet thisAlerts:
@k0r54authorAug 13.2004 — I have taken out the semi-colon that was a mistake but the same error is happend as before unexpected $end on line 39 ?> i have used the code (copied it) from nogdog post but still dont work.

the outline is:

connects to databse (itemsone) and if item number and winneruserid match up it will then connect to another table and pull the other information out aswell. then when i echo it out i can use the information in the echo from both tables.

This did work until i put in the function (//display html) bit

but i then put it back and it still dont work

Am i doin something wrong

thanks Adam
Copy linkTweet thisAlerts:
@k0r54authorAug 13.2004 — Does any1 have any idea, i have been working on it solid lol

Thanks Adz
Copy linkTweet thisAlerts:
@Paul_JrAug 13.2004 — [code=php]
<?PHP
require_once('page_build.php');
//conn
$conn = mysql_connect("localhost", "k0m0d0", "ragnarok") or die(mysql_error());
//select db
mysql_select_db("ebay",$conn) or die(mysql_error());
//statement
$sql = "SELECT AuctionID, WinnerUserID FROM itemswon WHERE WinnerUserID =
'$_POST[eBayUserID]' AND eBayItemNumber = '$_POST[eBayItemNumber]'";
//if script
$result = mysql_query($sql, $conn) or die(mysql_error());
if (mysql_num_rows($result) ==1)
{
//fetch results
$row = mysql_fetch_array($result);
//extract is into the echo
extract($row);
//new sql statement
$sql2 = "SELECT Title, SubTitle FROM auctions WHERE ID = '$AuctionID'";
//run the query
$result2 = mysql_query($sql2, $conn) or die(mysql_error());
if (mysql_num_rows($result2) ==1)
{
//fetch results
$row2 = mysql_fetch_array($result2);
//extract is into the echo
extract($row2);
//display HTML from the page_build
page_header();
ebay_2();
page_footer();
// If the eBayItemNumber dont exist
}
else
{
echo "Your eBayUserID";
} // <<-- NogDog's comment: why is this semi-colon here?
}
?>
[/code]

Try that.
Copy linkTweet thisAlerts:
@k0r54authorAug 13.2004 — No it is still comin up blank

Is there anything else i should try or anything else you want to see like the html coe before it is


<!--PHP Break --><form name="login" action="ebay_1.php">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td><img src="file:///C|/Documents%20and%20Settings/Adam/My%20Documents/Apc-Compunet/Sources/Web%20Sites/Apc-Compunet/Source/New/images/ebay/after_sales/ebaylogo.JPG" width="150" height="70"></td>

</tr>

<tr>

<td>

<p class="subtopicmain"><strong>Congratulations! <br>

Please login to complete the transaction</strong></p>

<p>Your eBay User ID<br>

<input name="eBayUserID" type="text" id="eBayUserID2">

</p>

<p>eBay Item Number<br>

<input name="eBayItemNumber" type="text" id="eBayItemNumber2">

</p>

<p>&nbsp; </p></td>

</tr>

<tr>

<td><input type="image" border="0" name="imageField" src="file:///C|/Documents%20and%20Settings/Adam/My%20Documents/Apc-Compunet/Sources/Web%20Sites/Apc-Compunet/Source/New/images/ebay/after_sales/next.jpg"></td>

</tr>

</table></form>

<!-- PHP END BREAK -->
[/QUOTE]


Thanks Adam
Copy linkTweet thisAlerts:
@Paul_JrAug 14.2004 — [i]Originally posted by k0r54 [/i]

[B]No it is still comin up blank[/B][/QUOTE]

But is the error gone?
Copy linkTweet thisAlerts:
@k0r54authorAug 14.2004 — Hi my fiend redone it and there is different problems now please look

[URL=http://www.webdeveloper.com/forum/showthread.php?s=&threadid=41779]Please look here for the new post and a different problem[/URL]

Many Thanks Adam
×

Success!

Help @k0r54 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...