Jump to content

T strings.


dean7

Recommended Posts

Hi all ive trying to code a comment like thing for my website where users can comment on other users profiles:

 

<?php
///////////// Start Of New Code ///////////////
///////////// Add Comment On Profile //////////

include ("config.php");
include ("makelogin.php");

////////////// Includes //////////////////

$username = $logged['username'];
$ul = $logged['userlevel'];
$msg=strip_tags($_POST['msg']);
$date = gmdate('Y-m-d h:i:s');

///////////// Starting Varibals //////////////////

$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);

///////////// Querys /////////////////////////

if($ul == "owner"){
if (strip_tags($_POST['submit'])
///////////////////// Line 158 is The One BELOW This ////////////////////////////////// 
mysql_query("INSERT INTO `pmessages` ( `id` , `title` , `from` , `message` , `date` , `unread` )
VALUES (
'', 'Profile Comment', '$username', '$msg', '$date', 'unread'
)");
echo ("<font color='black'>Comment Sent To $username!");
}

///////////// Sending The Comment They Sent ///////////////////
?>

<html>
<form method="post" action="">
<table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'>
<tr>
<td>
  <p align="center">Comment To Send: <br>
</td>
</tr>
<tr>
<td>
    <textarea name="msg" cols="40" rows="8" id="msg"></textarea>
</td>	
</tr>
<tr>
</td>
    <input type="submit" value="Send Comment">
</td>
</tr>
</table>
</form>
</html>

 

I have an error saying :

Parse error: syntax error, unexpected T_STRING in /home/a7502957/public_html/members.php on line 158

 

Any one know why?

Thanks

Link to comment
Share on other sites

Parse error: syntax error, unexpected T_STRING in /home/a7502957/public_html/members.php on line 158

 

It would be great if you could highlight the line of code the parser is telling you to check.  It may well be the actual issue is before this line so if you could show the code in members.php (as much as possible) so that we can see line 158 and what code relates to it.

Link to comment
Share on other sites

try this:

 

<?php
///////////// Start Of New Code ///////////////
///////////// Add Comment On Profile //////////

include ("config.php");
include ("makelogin.php");

////////////// Includes //////////////////

$username = $logged['username'];
$ul = $logged['userlevel'];
$msg=strip_tags($_POST['msg']);
$date = gmdate('Y-m-d h:i:s');

///////////// Starting Varibals //////////////////

$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);

///////////// Querys /////////////////////////

if($ul == "owner"){
if (strip_tags($_POST['submit']))
///////////////////// Line 158 is The One BELOW This ////////////////////////////////// 
mysql_query("INSERT INTO pmessages ('id','title','from','message','date','unread')
VALUES (
'', 'Profile Comment', '$username', '$msg', '$date', 'unread'
)");
echo "<font color='black'>Comment Sent To $username!";
}

///////////// Sending The Comment They Sent ///////////////////
?>

<html>
<form method="post" action="">
<table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'>
<tr>
<td>
  <p align="center">Comment To Send: <br>
</td>
</tr>
<tr>
<td>
    <textarea name="msg" cols="40" rows="8" id="msg"></textarea>
</td>




</tr>
<tr>
</td>
    <input type="submit" value="Send Comment">
</td>
</tr>
</table>
</form>
</html>

Link to comment
Share on other sites

 if($ul == "owner"){
if (strip_tags($_POST['submit'])
///////////////////// Line 158 is The One BELOW This ////////////////////////////////// 
mysql_query("INSERT INTO `pmessages` ( `id` , `title` , `from` , `message` , `date` , `unread` )
VALUES (
'', 'Profile Comment', '$username', '$msg', '$date', 'unread'
)");
echo ("<font color='black'>Comment Sent To $username!");
}

 

Either I learned something or I see one thing you are doing wrong.  At "if (strip_tags($_POST['submit'])" there is no "{". Now I could be wrong, but whats the point of an "if" if there is no "{"?

Link to comment
Share on other sites

Parse error: syntax error, unexpected T_STRING in /home/a7502957/public_html/members.php on line 158

 

It would be great if you could highlight the line of code the parser is telling you to check.  It may well be the actual issue is before this line so if you could show the code in members.php (as much as possible) so that we can see line 158 and what code relates to it.

I could show you all of my members.php file if you want? But that code there is basicly the comment system. Before i added that there it all work good..

 

But here is members.php with the other code in it.:

 

<?php
include('css/style.css');
include("makelogin.php");
include("functions.php");
?>
<?
session_start();
ob_start();
include("config.php");
if (!$_GET[user])
{
$getuser = mysql_query("SELECT * from users order by id asc");
while ($user = mysql_fetch_array($getuser))
{
// gets all the users information. 
echo ("<a href=\"members.php?user=$user[username]\">$user[username]</a><br />\n");
// links to a page to view the user's profile.
}
}
ELSE
{
$getuser = mysql_query("SELECT * from users where username = '$_GET[user]'");
$usernum = mysql_num_rows($getuser);
if ($usernum == 0)
{
echo ("User Not Found");
}
else
{
$profile = mysql_fetch_array($getuser);
echo ("<center><table width='70%' border='1px' bordercolor='#000000' bgcolor='#666666'>
<tr>
<td background='tableheader.png'>
<center><font color='black'>$profile[username] Profile</font></center>
</td>
</tr>
</table>
<table width='70%' border='1px' bordercolor='#000000' bgcolor='#666666'>
<tr>
<td>
Username:
</td>
<td>
<a href=\"messages.php?page=write\">$profile[username]</a>
</td>
<td>
Email:
</td>
<td>
$profile[email]
</td>
</tr>
<tr>
<td>
Msn:
</td>
<td>
$profile[msn]
</td>
<td>
Aim:
</td>
<td>
$profile[aim]
</td>
</tr>
<tr>
<td>
Reg Date:
</td>
<td>
0000,00,00
</td>
<td>
Last Login:
</td>
<td>
0000,00,00
</td>
</tr>
<tr>
<td>
Location:
</td>
<td>
$profile[location]
</td>
<td>
Id:
</td>
<td>
$profile[id]
</td>
</tr>
<tr>
<td>
Level:
</td>
<td>
$profile[level]
</td>
<td>
Game Crew:
</td>
<td>
$profile[gamecrew]
</td>
</tr>
<tr>
<td>
Game Comment:
</td>
<td>
$profile[comment]
</td>
</tr>
</table>
<table width='70%' border='1px' bordercolor='#000000' bgcolor='#666666'>
<tr>
<td background='tableheader.png'>
<center><font color='black'>Content</font></center>
</td>
</tr>
<tr>
<td>
$profile[content]
</td>
</tr>
</table></center>");
// in the above code, we display the user's information.
}
}
?>

<?php
///////////// Start Of New Code ///////////////
///////////// Add Comment On Profile //////////

include ("config.php");
include ("makelogin.php");

////////////// Includes //////////////////

$username = $logged['username'];
$ul = $logged['userlevel'];
$msg=strip_tags($_POST['msg']);
$date = gmdate('Y-m-d h:i:s');

///////////// Starting Varibals //////////////////

$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);

///////////// Querys /////////////////////////

if($ul == "owner"){
if (strip_tags($_POST['submit'])
mysql_query("INSERT INTO `pmessages` ( `id` , `title` , `from` , `message` , `date` , `unread` )
VALUES (
'', 'Profile Comment', '$username', '$msg', '$date', 'unread'
)");
echo ("<font color='black'>Comment Sent To $username!");
}

///////////// Sending The Comment They Sent ///////////////////
?>

<html>
<form method="post" action="">
<table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'>
<tr>
<td>
  <p align="center">Comment To Send: <br>
</td>
</tr>
<tr>
<td>
    <textarea name="msg" cols="40" rows="8" id="msg"></textarea>
</td>	
</tr>
<tr>
</td>
    <input type="submit" value="Send Comment">
</td>
</tr>
</table>
</form>
</html>

 

Sorry about length

Link to comment
Share on other sites

try this:

 

<?php
///////////// Start Of New Code ///////////////
///////////// Add Comment On Profile //////////

include ("config.php");
include ("makelogin.php");

////////////// Includes //////////////////

$username = $logged['username'];
$ul = $logged['userlevel'];
$msg=strip_tags($_POST['msg']);
$date = gmdate('Y-m-d h:i:s');

///////////// Starting Varibals //////////////////

$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);

///////////// Querys /////////////////////////

if($ul == "owner"){
if (strip_tags($_POST['submit']))
///////////////////// Line 158 is The One BELOW This ////////////////////////////////// 
mysql_query("INSERT INTO pmessages ('id','title','from','message','date','unread')
VALUES (
'', 'Profile Comment', '$username', '$msg', '$date', 'unread'
)");
echo "<font color='black'>Comment Sent To $username!";
}

///////////// Sending The Comment They Sent ///////////////////
?>

<html>
<form method="post" action="">
<table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'>
<tr>
<td>
  <p align="center">Comment To Send: <br>
</td>
</tr>
<tr>
<td>
    <textarea name="msg" cols="40" rows="8" id="msg"></textarea>
</td>




</tr>
<tr>
</td>
    <input type="submit" value="Send Comment">
</td>
</tr>
</table>
</form>
</html>

That worked, Just now it isnt incerting into the database.

Link to comment
Share on other sites

all apologies - I didn't see the comment in the line code... - my bad.

 

ngreenwood picked up the missing brace on the if...

 

I wasn't talking about the ")" which is one thing, but I just meant the "{" and "}" on the if. What does the "if" even do if there is no "{" and "}"?

 

EDIT: Err nevermind.

Link to comment
Share on other sites

all apologies - I didn't see the comment in the line code... - my bad.

 

ngreenwood picked up the missing brace on the if...

 

I wasn't talking about the ")" which is one thing, but I just meant the "{" and "}" on the if. What does the "if" even do if there is no "{" and "}"?

 

Ive added the "{" and "}" in but i dont think i did any difference.

Link to comment
Share on other sites

try this then:

 

<?php
///////////// Start Of New Code ///////////////
///////////// Add Comment On Profile //////////

include ("config.php");
include ("makelogin.php");

////////////// Includes //////////////////

$username = $logged['username'];
$ul = $logged['userlevel'];
$msg=strip_tags($_POST['msg']);
$date = gmdate('Y-m-d h:i:s');

///////////// Starting Varibals //////////////////

$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);

///////////// Querys /////////////////////////

if($ul == "owner"){
if ($_POST['submit'])
{
///////////////////// Line 158 is The One BELOW This ////////////////////////////////// 
mysql_query("INSERT INTO pmessages ('id','title','from','message','date','unread') VALUES ('','Profile Comment','$username','$msg','$date','unread')");
echo "<font color='black'>Comment Sent To $username!";
}
}

///////////// Sending The Comment They Sent ///////////////////
?>

<html>
<form method="post" action="">
<table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'>
<tr>
<td>
  <p align="center">Comment To Send: <br>
</td>
</tr>
<tr>
<td>
    <textarea name="msg" cols="40" rows="8" id="msg"></textarea>
</td>




</tr>
<tr>
</td>
    <input type="submit" name="submit" value="Send Comment">
</td>
</tr>
</table>
</form>
</html>

Link to comment
Share on other sites

try this then:

 

<?php
///////////// Start Of New Code ///////////////
///////////// Add Comment On Profile //////////

include ("config.php");
include ("makelogin.php");

////////////// Includes //////////////////

$username = $logged['username'];
$ul = $logged['userlevel'];
$msg=strip_tags($_POST['msg']);
$date = gmdate('Y-m-d h:i:s');

///////////// Starting Varibals //////////////////

$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);

///////////// Querys /////////////////////////

if ($_POST['submit'])
{
///////////////////// Line 158 is The One BELOW This ////////////////////////////////// 
mysql_query("INSERT INTO pmessages ('id','title','from','message','date','unread') VALUES ('','Profile Comment','$username','$msg','$date','unread')");
echo "<font color='black'>Comment Sent To $username!";
}


///////////// Sending The Comment They Sent ///////////////////
?>

<html>
<form method="post" action="">
<table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'>
<tr>
<td>
  <p align="center">Comment To Send: <br>
</td>
</tr>
<tr>
<td>
    <textarea name="msg" cols="40" rows="8" id="msg"></textarea>
</td>

   


</tr>
<tr>
</td>
    <input type="submit" name="submit" value="Send Comment">
</td>
</tr>
</table>
</form>
</html>

Link to comment
Share on other sites

Sorry its late and i am slipping lol. try this and if it gives you an error tell me what it was:

 

<?php
///////////// Start Of New Code ///////////////
///////////// Add Comment On Profile //////////

include ("config.php");
include ("makelogin.php");

////////////// Includes //////////////////

$username = $logged['username'];
$ul = $logged['userlevel'];
$msg=strip_tags($_POST['msg']);
$date = gmdate('Y-m-d h:i:s');

///////////// Starting Varibals //////////////////

$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);

///////////// Querys /////////////////////////

if ($_POST['submit'])
{
///////////////////// Line 158 is The One BELOW This ////////////////////////////////// 
mysql_query("INSERT INTO pmessages (id,title,from,message,date,unread) VALUES('','Profile Comment','$username','$msg','$date','unread')") or die(mysql_error());
echo "<font color='black'>Comment Sent To $username!";
}


///////////// Sending The Comment They Sent ///////////////////
?>

<html>
<form method="post" action="">
<table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'>
<tr>
<td>
  <p align="center">Comment To Send: <br>
</td>
</tr>
<tr>
<td>
    <textarea name="msg" cols="40" rows="8" id="msg"></textarea>
</td>

   


</tr>
<tr>
</td>
    <input type="submit" name="submit" value="Send Comment">
</td>
</tr>
</table>
</form>
</html>

Link to comment
Share on other sites

When i click reply it show this:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from,message,date,unread) VALUES('','Profile Comment','dean7','fdgdfg','2009-09-' at line 1

Link to comment
Share on other sites

also with the code

 

<?php
///////////// Start Of New Code ///////////////
///////////// Add Comment On Profile //////////

include ("config.php");
include ("makelogin.php");

////////////// Includes //////////////////

$username = $logged['username'];
$ul = $logged['userlevel'];
$msg=strip_tags($_POST['msg']);
$date = gmdate('Y-m-d h:i:s');

///////////// Starting Varibals //////////////////

$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);

///////////// Querys /////////////////////////

if ($_POST['submit'])
{
///////////////////// Line 158 is The One BELOW This ////////////////////////////////// 
mysql_query("INSERT INTO pmessages ('id','title','from','message','date','unread') VALUES ('','Profile Comment','$username','$msg','$date','unread')");
echo "<font color='black'>Comment Sent To $username!";
}


///////////// Sending The Comment They Sent ///////////////////
?>

<html>
<form method="post" action="">
<table width='80%' cellspacing='0' cellpadding='0' border='1' bordercolor='#000000'>
<tr>
<td>
  <p align="center">Comment To Send: <br>
</td>
</tr>
<tr>
<td>
    <textarea name="msg" cols="40" rows="8" id="msg"></textarea>
</td>

   


</tr>
<tr>
</td>
    <input type="submit" name="submit" value="Send Comment">
</td>
</tr>
</table>
</form>
</html>

 

It does echo who its sent to just dont insert it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.