Forum Moderators: coopster

Message Too Old, No Replies

PHP Parse error: syntax error, unexpected T STRING

         

Champing

4:41 pm on Dec 7, 2011 (gmt 0)

10+ Year Member



Hello,

I am currently trying to make a furni shop for my habbo retro server, I'm nearly finished but I'm getting this:

[07-Dec-2011 08:33:13] PHP Parse error: syntax error, unexpected T_STRING in C:\inetpub\wwwroot\insertfurni.php on line 24


The code of the whole page is:

<?php

require_once "/global.php";

$q = mysql_query("SELECT * FROM users WHERE username = '" . USER_NAME . "'") or DIE (mysql_error());
while($row = mysql_fetch_array($q)) {
$belcredits = $row["belcredits"];
$userid = $row["id"];
}

$q2 = mysql_query("SELECT * FROM items ORDER BY id DESC LIMIT 1") or DIE (mysql_error());
while($row2 = mysql_fetch_array($q2)) {
$fid = $row2["id"] + 15;
}
if ($belcredits <= 49)
{
echo "Je hebt niet genoeg belcredits.";
}
else
{

mysql_query("INSERT INTO items (id, user_id, base_item, extra_data, wall_pos) VALUES ('$fid','$userid', '202', '', '')")
mysql_query("UPDATE users SET belcredits = belcredits - 50 WHERE username = '".USER_NAME."'");
echo "Je hebt de meubel ontvangen ! - Wacht 5 seconden we brengen je terug naar de site";
or DIE (mysql_error());
}

?>


Anyone who sees the problem? Really need to fix this tonight .. thanks in advance!

eelixduppy

4:46 pm on Dec 7, 2011 (gmt 0)



Hello and Welcome to WebmasterWorld!

It appears you have some code in there that shouldn't be:

echo "Je hebt de meubel ontvangen ! - Wacht 5 seconden we brengen je terug naar de site";
or DIE (mysql_error());


Remove the bold code and it should work.

Champing

4:50 pm on Dec 7, 2011 (gmt 0)

10+ Year Member



Thanks,

I did this but I still get the same error ..

If I remove this part:

[php]mysql_query("UPDATE users SET belcredits = belcredits - 50 WHERE username = '".USER_NAME."'");
echo "Je hebt de meubel ontvangen ! - Wacht 5 seconden we brengen je terug naar de site";[/php] it does work so it should be something in there ..

Champing

4:53 pm on Dec 7, 2011 (gmt 0)

10+ Year Member



Someone on another forum posted this as a fix and it worked:

<?php
require_once "/global.php";
$q = mysql_query("SELECT * FROM users WHERE username = '" . USER_NAME . "'") or DIE (mysql_error());
while($row = mysql_fetch_array($q)) {
$belcredits = $row["belcredits"];
$userid = $row["id"];
}
$q2 = mysql_query("SELECT * FROM items ORDER BY id DESC LIMIT 1") or DIE (mysql_error());
while($row2 = mysql_fetch_array($q2)) {
$fid = $row2["id"] + 15;
}
if ($belcredits <= 49){
echo "Je hebt niet genoeg belcredits.";
}else{
mysql_query("INSERT INTO items (id, user_id, base_item, extra_data, wall_pos) VALUES ('$fid','$userid', '202', '', '')") or die(mysql_error());
mysql_query("UPDATE users SET belcredits = belcredits - 50 WHERE username = \"".USER_NAME."\"") or die(mysql_error());
echo "Je hebt de meubel ontvangen ! - Wacht 5 seconden we brengen je terug naar de site";
}
?>

eelixduppy

5:05 pm on Dec 7, 2011 (gmt 0)



You were actually also missing a semi-colon at the end of this line, which is the reason for the error you gave:

mysql_query("INSERT INTO items (id, user_id, base_item, extra_data, wall_pos) VALUES ('$fid','$userid', '202', '', '')")