Jump to content


bit of php help


2 replies to this topic

#1 Warbz

    IRC is just a multiplayer notepad.

  • Project Team
  • 4646 posts

Posted 25 January 2008 - 18:25

Im trying to make a php comment box on my webpage, Bob helped me make one before and this is basically the same but with a few tweaks, and i lost the original code.

Now all this new code does is show this...

warbz18.aexwow.com/comment.php

heres the code...

<!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;>
<html xmlns=&#34;http&#58;//www.w3.org/1999/xhtml&#34;>
<head>
<meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=iso-8859-1&#34; />
<title>Comment</title>
</head>

<html>

<body>

<;? 

$dbHandle = sqlite_open&#40;&#39;database.sqlite2&#39;, 0666, $sqliteError&#41; or die&#40;$sqliteError&#41;; 

if &#40;isset&#40;$_POST&#91;&#39;button&#39;&#93;&#41;&#41;{ 

$username = &#40;isset&#40;$_POST&#91;&#39;username&#39;&#93;&#41;&#41; ? $_POST&#91;&#39;username&#39;&#93; &#58; &#39;&#39;&#59; 
$comment = &#40;isset&#40;$_POST&#91;&#39;comment&#39;&#93;&#41;&#41; ? $_POST&#91;&#39;comment&#39;&#93; &#58; &#39;&#39;&#59; 

$sqlCreateTable = &#39;CREATE TABLE commenttable&#40;id INTEGER PRIMARY KEY, username CHAR&#40;256&#41;, comment CHAR&#40;256&#41;&#41;&#39;; 
@sqlite_exec&#40;$dbHandle, $sqlCreateTable&#41;; 

$sqlInsertComment = &#39;INSERT INTO commenttable &#40;username, comment&#41; VALUES &#40;\&#39;&#39;.$username.&#39;\&#39;, \&#39;&#39;.$comment.&#39;\&#39;&#41;&#39;; 
sqlite_exec&#40;$dbHandle, $sqlInsertComment&#41;; 

} ?><form action=&#34;<;?php echo $_SERVER&#91;&#39;PHP_SELF&#39;&#93;; ?>&#34; method=&#34;post&#34; name=&#34;commentform&#34; > Name&#58; <input type=&#34;text&#34; name=&#34;username&#34;><br/> Comment&#58; <textarea name=&#34;comment&#34;></textarea><br/> <input type=&#34;submit&#34; name=&#34;button&#34; value=&#34;submit&#34;></form><table><;? 

$query = sqlite_query&#40;$dbHandle, &#34;SELECT id, username, comment FROM commenttable ORDER BY id DESC&#34;&#41;; 


while &#40;$entry = sqlite_fetch_array&#40;$query, SQLITE_ASSOC&#41;&#41;
{ ?><tr> <td> <;? echo $entry&#91;&#39;username&#39;&#93;; ?> says
</td> <td> &#34;<;? echo $entry&#91;&#39;comment&#39;&#93;; ?>&#34; 
</td></tr><;? } 

?>

</body>
</html>


Any help in making it work would be appreciated

Posted Image

#2 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 25 January 2008 - 18:48

What exactly is '<;?' ? Shouldn't you just use '<?php' ?
CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb

#3 Warbz

    IRC is just a multiplayer notepad.

  • Project Team
  • 4646 posts

Posted 25 January 2008 - 21:24

yeh a mate of mine spotted it shortly after I posted it here.
Silly mistake. All sorted now.

Posted Image



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users