Page 1 of 1
error in my script
Posted: Sat Jul 25, 2009 3:33 am
by mayanktalwar1988
Code: Select all
<?php
if (isset($_GET['id'])){
$host = "localhost";
$user = "root";
$pass = "";
$db = "ask";
$con = mysql_connect($host,$user,$pass);
mysql_select_db($db,$con);
$id = $_GET['id'];
echo "<a href=\"create_topic.php?id=$id\">New topic</a>";
echo "<table border='0' width='100%'>";
$sql = mysql_query("SELECT * FROM topics WHERE cat_id='".$id."'");
while($row = mysql_fetch_array($sql)) {
echo "<tr><td><a href='show_reply.php?cat_id=\"$id\"&topic_id=\"$row['id']\"'>".htmlentities($row['title'])."</a></td></tr>
<tr><td><a href='mailto:".$row['mail']."'>".htmlentities($row['author'])."</a></td></tr>
<tr><td>".date("j/n - y",$row['date'])."</td></tr>";
}
echo "</table>";
mysql_close($con);
} else {
echo "invalid usage!";
}
?>
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\customo\topic.php on line 18
Re: error in my script
Posted: Sat Jul 25, 2009 5:45 am
by jackpf
Try putting curly braces around $row['id'].
Re: error in my script
Posted: Sat Jul 25, 2009 6:02 am
by mayanktalwar1988
yes jack that worked but why the prevoius code didnt worked
Re: error in my script
Posted: Sat Jul 25, 2009 6:06 am
by mayanktalwar1988
jack i am building a simple forum..i have simple reply box..and i want to add clickable smileys just like phpbb forum ...how to do it..i know i am asking for more..

Re: error in my script
Posted: Sat Jul 25, 2009 6:28 am
by jackpf
mayanktalwar1988 wrote:yes jack that worked but why the prevoius code didnt worked
Idk, something to do with PHP not parsing arrays in double quotes very well I guess...you should always use curly braces, or concatenation when echoing arrays with double quotes. I personally use single quotes, just preference tbh.
And that would be javascript.
I've actually created my own forum,
http://jackpf.co.uk/forum, and I have something similar to that (with bbcode rather than smileys though). If you just want it to place the smileys into a textarea, you could do something like this:
Code: Select all
function newSmiley(smiley)
{
document.getElementsByTagName('textarea')[0].innerHTML += ' '+smiley+' ';
}
However, if you want something more advanced, with selection areas, you can just take a look at my js.js file on my site. The code() function is what I wrote to handle selection areas, and inserting wherever the cursor currently is.
Re: error in my script
Posted: Sat Jul 25, 2009 8:10 am
by mayanktalwar1988
ok jack thanks...i got it