Iank1968 Posted March 1, 2009 Share Posted March 1, 2009 I get this error everytime I try to access the landmarks page: Parse error: syntax error, unexpected '<' in /home/ianapps/public_html/globetrotters/common.php on line 114 114 is <? Here is the code <? <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> ?> I cant figure out whats wrong. Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/ Share on other sites More sharing options...
Mchl Posted March 1, 2009 Share Posted March 1, 2009 What is before that? Did you close previous PHP tag? You can't just write HTML within PHP tags like that. Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774050 Share on other sites More sharing options...
Iank1968 Posted March 1, 2009 Author Share Posted March 1, 2009 I just realized this is in the wrong forum ooops lol. Anyhow I did have an open tag and closed it now I have the parse error in line 115 this is before that } function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774053 Share on other sites More sharing options...
Iank1968 Posted March 1, 2009 Author Share Posted March 1, 2009 so how would I write that bit of code in php? Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774055 Share on other sites More sharing options...
Mchl Posted March 1, 2009 Share Posted March 1, 2009 Like that: <?php // some php } function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } ?> <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> <?php //more php ?> Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774061 Share on other sites More sharing options...
Iank1968 Posted March 1, 2009 Author Share Posted March 1, 2009 Well that didnt work, no I get that error in line 109 which is <?php heres the code now <?php //some php function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } <? <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> <?php ?> Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774074 Share on other sites More sharing options...
Mchl Posted March 1, 2009 Share Posted March 1, 2009 This isn't exactly what I posted above. There's one difference. Very small but extremely important. Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774090 Share on other sites More sharing options...
daveoffy Posted March 1, 2009 Share Posted March 1, 2009 Like that: <?php // some php } function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } ?> <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> <?php //more php ?> This is right, but for you I think you want the following (COPY AND PASTE) <?php // some php } function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } ?> <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> If you want to add more php put in <?php your code here than close it with ?> Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774100 Share on other sites More sharing options...
jackpf Posted March 1, 2009 Share Posted March 1, 2009 Or you could just not close the php tag and echo the whole table thing. I personally think it's better coding practice. Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774109 Share on other sites More sharing options...
Iank1968 Posted March 2, 2009 Author Share Posted March 2, 2009 Well I did as you said and I still get the same error. Its like it doesnt like <? or <?php <?php // some php } function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } ?> <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774401 Share on other sites More sharing options...
daviddth Posted March 2, 2009 Share Posted March 2, 2009 Might be an idea to post a bit more of the code prior to the error - are there any php sections before it that are not closed properly etc? <?php // some php } //<<<<<<<<<<<<< Why are you closing a bracket thats not opened, unless it's opened in a previous section? function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774417 Share on other sites More sharing options...
Philip Posted March 2, 2009 Share Posted March 2, 2009 Post your full code, not just // some php Something in that some php it whats causing your error most likely. Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774418 Share on other sites More sharing options...
Iank1968 Posted March 2, 2009 Author Share Posted March 2, 2009 this is on my common.php file, its 2000 lines long, dont think you want it all do you? I will give you a few lines before that function. I got rid of that bracket and still got the parse error function GetInTradesSideBar ($user) { global $logtrade_table; $result = Query ("SELECT id,unix_timestamp(date) as datets,uid_from,what,amt,what_req,amt_req,auth FROM $logtrade_table WHERE uid_to=$user and hide=0 and auth=0 ORDER by date DESC"); // get trades coming into you $i=0; if (mysql_num_rows ($result) == 0) return "<br/>."; $a = '<table>'; while ($row = mysql_fetch_array ($result)) { $u = $row['uid_from']; $a .= '<tr><td bgcolor="#eaeaea"><fb:profile-pic uid="'.$u.'"/> <br/><fb:name uid="'.$u.'"/></td><td bgcolor="#eaeaea">' . date ("F j", $row['datets'] ) . ' - <b><a href="?id=trade">View</a></b></td></tr>'; $i++; } $a .= '</table>'; return $a; } function GetOutTrades ($user) { global $logtrade_table; $result = Query ("SELECT id,unix_timestamp(date) as datets,uid_to,what,amt,what_req,amt_req,auth,hide FROM $logtrade_table WHERE uid_from=$user ORDER by date DESC limit 50 "); // get trades coming into you $i=0; while ($row = mysql_fetch_array ($result)) { $out[$i]['id'] = $row['id']; $out[$i]['date'] = $row['datets']; $out[$i]['uid_to'] = $row['uid_to']; $out[$i]['what'] = $row['what']; $out[$i]['amt'] = $row['amt']; $out[$i]['what_req'] = $row['what_req']; $out[$i]['amt_req'] = $row['amt_req']; $out[$i]['auth'] = $row['auth']; $out[$i]['hide'] = $row['hide']; $i++; } return $out; } <?php // some php function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } ?> <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> line 109 is <?php Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774419 Share on other sites More sharing options...
daviddth Posted March 2, 2009 Share Posted March 2, 2009 your opening another <?php section while still IN one. Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774421 Share on other sites More sharing options...
Iank1968 Posted March 2, 2009 Author Share Posted March 2, 2009 I did by accident, its gone now lol Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774423 Share on other sites More sharing options...
Iank1968 Posted March 2, 2009 Author Share Posted March 2, 2009 so what do I do now? Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774425 Share on other sites More sharing options...
Iank1968 Posted March 2, 2009 Author Share Posted March 2, 2009 ok I took out <?php ?> and now its saying Parse error: syntax error, unexpected '<' in /home/ianapps/public_html/globetrotters/common.php on line 118 line 118 - 120 <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774429 Share on other sites More sharing options...
daviddth Posted March 2, 2009 Share Posted March 2, 2009 Can you post 10 or so lines up to the error point and the same after. At a guess that's in a php section as above Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774434 Share on other sites More sharing options...
Iank1968 Posted March 2, 2009 Author Share Posted March 2, 2009 ok I am gonna post from line 1 to just past the error. <?php require 'settings.php'; $username = "ianapps"; $password = "wdLlGQbZlswP"; $hostname = "localhost"; $conn = mysql_connect ($dbhost, $dbuser, $dbpass); $sel = mysql_select_db ($dbname, $conn); if (!$sel || !$conn) { exit; } function Query ($q) { global $conn; $result = mysql_query ($q, $conn); if (!$result) { } return $result; } function getprizeproperty($fprize) { } function TransferPrize ($from, $to, $prize, $amt) { if (GetPrizeProperty ($from, $prize) >= $amt) { ChangePrizeProperty ($from, $prize, -$amt, false); ChangePrizeProperty ($to, $prize, $amt, false); return true; } return false; } function TransferMoney ($from, $to, $amt) { if (GetMoney ($from) >= $amt*100) { AlterMoney ($from, -$amt*100); AlterMoney ($to, $amt*100); return true; } return false; } function IsThereEnough ($uid, $what, $amt) { if ($what == 'money') { if (GetMoney ($uid) < $amt) return false; } else { if (GetPrizeProperty ($uid, $what) < $amt) return false; } return true; } function LogStealAttempt ($user_from, $user_to, $what, $amt) { global $logsendneg_table; Query ("INSERT INTO $logsendneg_table SET uid_from=$user_from, uid_to=$user_to, what='$what', amt=$amt"); } function LogSend ($user_from, $user_to, $what, $amt, $trade=0) { global $logsend_table; Query ("INSERT INTO $logsend_table SET uid_from=$user_from, uid_to=$user_to, what='$what', amt=$amt, trade=$trade"); } function LogTrade ($user_from, $user_to, $tx_what, $tx_amt, $rx_what, $rx_amt) { global $logtrade_table; Query ("INSERT INTO $logtrade_table SET uid_from=$user_from, uid_to=$user_to, what='$tx_what', amt=$tx_amt, what_req='$rx_what', amt_req=$rx_amt"); } function GetInTrades ($user) { global $logtrade_table; $result = Query ("SELECT id,unix_timestamp(date) as datets,uid_from,what,amt,what_req,amt_req,auth FROM $logtrade_table WHERE uid_to=$user and hide=0 and auth=0 ORDER by date DESC"); // get trades coming into you $i=0; while ($row = mysql_fetch_array ($result)) { $in[$i]['id'] = $row['id']; $in[$i]['date'] = $row['datets']; $in[$i]['uid_from'] = $row['uid_from']; $in[$i]['what'] = $row['what']; $in[$i]['amt'] = $row['amt']; $in[$i]['what_req'] = $row['what_req']; $in[$i]['amt_req'] = $row['amt_req']; $in[$i]['auth'] = $row['auth']; $i++; } return $in; } function GetInTradesSideBar ($user) { global $logtrade_table; $result = Query ("SELECT id,unix_timestamp(date) as datets,uid_from,what,amt,what_req,amt_req,auth FROM $logtrade_table WHERE uid_to=$user and hide=0 and auth=0 ORDER by date DESC"); // get trades coming into you $i=0; if (mysql_num_rows ($result) == 0) return "<br/>."; $a = '<table>'; while ($row = mysql_fetch_array ($result)) { $u = $row['uid_from']; $a .= '<tr><td bgcolor="#eaeaea"><fb:profile-pic uid="'.$u.'"/> <br/><fb:name uid="'.$u.'"/></td><td bgcolor="#eaeaea">' . date ("F j", $row['datets'] ) . ' - <b><a href="?id=trade">View</a></b></td></tr>'; $i++; } $a .= '</table>'; return $a; } function GetOutTrades ($user) { global $logtrade_table; $result = Query ("SELECT id,unix_timestamp(date) as datets,uid_to,what,amt,what_req,amt_req,auth,hide FROM $logtrade_table WHERE uid_from=$user ORDER by date DESC limit 50 "); // get trades coming into you $i=0; while ($row = mysql_fetch_array ($result)) { $out[$i]['id'] = $row['id']; $out[$i]['date'] = $row['datets']; $out[$i]['uid_to'] = $row['uid_to']; $out[$i]['what'] = $row['what']; $out[$i]['amt'] = $row['amt']; $out[$i]['what_req'] = $row['what_req']; $out[$i]['amt_req'] = $row['amt_req']; $out[$i]['auth'] = $row['auth']; $out[$i]['hide'] = $row['hide']; $i++; } return $out; } // some php function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774436 Share on other sites More sharing options...
daviddth Posted March 2, 2009 Share Posted March 2, 2009 I'll look when I get home as the iPhone browser will not let me scroll a text box like that grrrrrr Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774439 Share on other sites More sharing options...
Iank1968 Posted March 2, 2009 Author Share Posted March 2, 2009 lol ok np. How long will that be? im in Toronto and its 1:30am. just wondering if I should wait up. Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774440 Share on other sites More sharing options...
daviddth Posted March 2, 2009 Share Posted March 2, 2009 At least an hour sorry. It's only 5:30 pm here in Australia. Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774441 Share on other sites More sharing options...
Iank1968 Posted March 2, 2009 Author Share Posted March 2, 2009 np I will be up still Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774442 Share on other sites More sharing options...
Mchl Posted March 2, 2009 Share Posted March 2, 2009 You have to close php tag, before you start your HTML Read this. It's the first chapter in PHP language reference. How do you want to write any PHP if you haven't read this? Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774454 Share on other sites More sharing options...
daviddth Posted March 2, 2009 Share Posted March 2, 2009 This is php code // some php function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } and this is HTML. <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> You can put html in a php section of code, but not like that. you have 2 options. This one closes the php tag, puts the html code, and then reopens it <?php //all your code was in here, but cut to make it easier to understand // some php function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } ?> <table border="0" colspacing="2" colpadding="2"> <tr> <th width="100"> <h3 class="subtitle">Date</h3> </th> <th width="120"> <h3 class="subtitle">Name</h3> </th> <th width="120"> <h3 class="subtitle">You Get</h3> </th> <th width="120"> <h3 class="subtitle">They want</h3> </th><th width="80"> <h3 class="subtitle">Action</h3> </th> </tr> <?php //any more php code goes here ?> or, my preference, simply use echo to write the html code. <?php //all your code was in here, but cut to make it easier to understand // some php function ParseInTrades ($data) { global $db_to_desc_send; if (!count($data)) return; global $facebook; } echo '<table border="0" colspacing="2" colpadding="2">'; echo '<tr><th width="100"><h3 class="subtitle">Date</h3></th><th width="120"><h3 class="subtitle">Name</h3></th><th width="120">'; echo '<h3 class="subtitle">You Get</h3></th><th width="120"><h3 class="subtitle">They want</h3></th><th width="80">'; echo '<h3 class="subtitle">Action</h3></th></tr>'; //any more php code goes here ?> Quote Link to comment https://forums.phpfreaks.com/topic/147466-getting-parse-error-syntax-error-unexpected/#findComment-774458 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.