6 Replies - 5659 Views - Last Post: 23 May 2011 - 09:08 AM Rate Topic: -----

#1 dangmnx  Icon User is offline

  • D.I.C Regular

Reputation: -1
  • View blog
  • Posts: 428
  • Joined: 10-April 09

Parse error: syntax error, unexpected T_STRING

Posted 22 May 2011 - 10:07 PM

I don't see where my error is coming from??

Quote

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /hermes/web04/b2008/moo.battlesccom/admineditusers.php on line 31


<?php
include("connect.php");
$query = mysql_query("SELECT * FROM members WHERE id='$id'")or die(mysql_error());
$result = mysql_fetch_assoc($query);
?>

<?php
include("connect.php");
$user = $_SESSION['user'];
//query
$get = mysql_query("SELECT admin FROM members WHERE setname='$user'");
while ($row = mysql_fetch_assoc($get))
{
 $admin = $row['admin'];
}

if ($admin !=0)
{
//show link
echo'<form action="adminuserupdate.php" method="post" name="frmedit" id="frmedit">';
echo'<table width="500" border="0" cellpadding="2" cellspacing="0" bordercolor="#EEE">';
echo'<tr>';
echo'<td>Username </td>';
echo'<td>First</td>';
echo'<td>Last</td>';
echo'<td>Signature</td>';
echo'</tr>';
echo'<tr>';

echo'<td><label>';
echo"<input name="setname" readonly="readonly" type="text" id="setname" value="<?php echo $result['setname']?>" />";
echo'</label></td>';

echo'<td><label>';
echo"<input name="aka" type="text" id="aka" value="<?php echo $result['aka']?>" />";
echo'</label></td>';

echo'<td><label>';
echo"<input name="aka1" type="text" id="aka1" value="<?php echo $result['aka1']?>" />";
echo'</label></td>';
      
echo'<td><label>';
echo"<input name="signature" type="text" id="signature" value="<?php echo $result['signature']?>" />";
echo'</label></td>';

echo'<tr>';
echo"<td><input name="id" type="hidden" id="id" value="<?php echo $_GET['id'];?>" /></td>";
echo'<td></td>';
echo'<td></td>';
echo'<td><label>';
echo'<input type="submit" name="button" id="button" value="Submit" />';
echo'</label></td>';
echo'<tr>';
echo'</table>';
echo'</form>';
}
?>


Is This A Good Question/Topic? 0
  • +

Replies To: Parse error: syntax error, unexpected T_STRING

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10183
  • View blog
  • Posts: 37,595
  • Joined: 27-December 08

Re: Parse error: syntax error, unexpected T_STRING

Posted 22 May 2011 - 10:10 PM

Take a look at line 31. You either need to escape the double-quotes within the echo String, like so: \", or you need to change those quotes in the echo String to single-quotes. Each double-quote is either opening or closing a separate String, non of which are legally concatenated.
echo "<input name="setname" readonly="readonly" type="text" id="setname" value="<?php echo $result['setname']?>" />"; 


Was This Post Helpful? 4
  • +
  • -

#3 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 922
  • View blog
  • Posts: 3,195
  • Joined: 19-January 10

Re: Parse error: syntax error, unexpected T_STRING

Posted 22 May 2011 - 10:58 PM

tl;dr line 31 should be:

echo "<input name=\"setname\" readonly=\"readonly\" type=\"text\" id=\"setname\" value=\"" . $result['setname'] . "\" />";


Was This Post Helpful? 1
  • +
  • -

#4 dangmnx  Icon User is offline

  • D.I.C Regular

Reputation: -1
  • View blog
  • Posts: 428
  • Joined: 10-April 09

Re: Parse error: syntax error, unexpected T_STRING

Posted 23 May 2011 - 03:37 AM

My code1 isn't displaying properly... can someone please tell me what's wrong? The default value in myphpadmin is

Quote

<img src="http://www.starcraftz.net/images/D.gif" alt="rank" />


echo'<td><label>';
echo "<input name=\"code1\" type=\"text\" id=\"code1\" value=\"" . $result['code1'] . "\" />";
echo'</label></td>';

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#5 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3635
  • View blog
  • Posts: 5,756
  • Joined: 08-June 10

Re: Parse error: syntax error, unexpected T_STRING

Posted 23 May 2011 - 03:56 AM

The default value in your MySQL database is the entire <img> tag?
If so, then that's a little weird. You would normally store the data that goes into the <img> tag, and then use PHP to create it using that data.

However, if for some reason you want the entire HTML tag to be stored and displayed in full, then you would have to convert it so it can be displayed as a string. - If you print a HTML tag into a HTML document, it will be read as a part of the HTML markup. If you want it read as a string value inside a HTML tag attribute, you need to convert the HTML special chars into HTML entities.

Fortunately PHP makes this easy, with the htmlentities() function. Run your HTML through that function before printing it, and you will see it in your page as a value, not as markup. -- Pay close attention to the third parameter if you are using Unicode, or any charset besides Latin-1 (ISO-8859-1).
Was This Post Helpful? 1
  • +
  • -

#6 dangmnx  Icon User is offline

  • D.I.C Regular

Reputation: -1
  • View blog
  • Posts: 428
  • Joined: 10-April 09

Re: Parse error: syntax error, unexpected T_STRING

Posted 23 May 2011 - 05:02 AM

So would this be correct?
<input type="text" name="code1" id="code" size="100" value="htmlentities (<?php echo $result['code']?>)" />

Attached image(s)

  • Attached Image

This post has been edited by dangmnx: 23 May 2011 - 05:03 AM

Was This Post Helpful? 0
  • +
  • -

#7 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 922
  • View blog
  • Posts: 3,195
  • Joined: 19-January 10

Re: Parse error: syntax error, unexpected T_STRING

Posted 23 May 2011 - 09:08 AM

View Postdangmnx, on 23 May 2011 - 06:02 AM, said:

So would this be correct?
<input type="text" name="code1" id="code" size="100" value="htmlentities (<?php echo $result['code']?>)" />


You do not need those PHP tags. I'm not sure how to explain it, so I'll let someone else do it for me.

Here's the fixed code.
echo '<input type="text" name="code1" id="code" size="100" value="' . htmlentities($result['code']) . '" />';

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1