Search
Left Quote    Nearly all men can stand adversity, but if you want to test a man's character, give him power.
- Abraham Lincoln    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Comment Script: Error
  This user is offline  chinako
  Subject: "Comment Script: Error" Posted: @ 5:14 pm on Oct 08 2007   
Member #: 421
Rank: User - (6)
Since: 09/27/07
Posts: 6
From: Reading, MA

I've uploaded the comments script to my server as well as the MySQL code to my database, but I'm getting the following error on the page that I'm using as a test-run for the code:

"Warning: main(/hsphere/l ocal/home/china ko/chinako.nu/p ath/to/file/com ments.php): failed to open stream: No such file or directory in /hsphere/local/ home/chinako/ch inako.nu/bswl/2 005.php on line 486

Warning: main(/hsphere/l ocal/home/china ko/chinako.nu/p ath/to/file/com ments.php): failed to open stream: No such file or directory in /hsphere/local/ home/chinako/ch inako.nu/bswl/2 005.php on line 486

Warning: main(): Failed opening '/hsphere/local /home/chinako/c hinako.nu/path/ to/file/comment s.php' for inclusion (include_path=' .:/usr/local/li b/php:/usr/loca l/share/pear') in /hsphere/local/ home/chinako/ch inako.nu/bswl/2 005.php on line 486"

I'm sure I've simply forgotten to switch out some of the directories within the code or something that is equally easy to resolve... can anyone show me where I've gone wrong?

The test page is here (all the way at the bottom of the page):
http://chinako. nu/bswl/2005.ph p

I've called the script "comments. php" and the MySQL database code is saved as "chinako_c omments". Any help would be appreciated!


    Viewed: 12,686 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Comment Script: Error" Posted: @ 6:18 pm on Oct 09 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

I see the problem i think. You're using the path:

/hsphere/loc al/home/chinako /chinako.nu/pat h/to/file/comme nts.php to tell PHP where the file is. Notice the /path/to/file ? You're suppose to replace that with the path to the file. Which appears to be: /bswl/ is that where you put it? if so, use this:

/hsphere/loc al/home/chinako /chinako.nu/bsw l/comments.php




-bs0d | AllSyntax.com

    Viewed: 12,669 Times | Reply to This | To top
  This user is offline  chinako
  Subject: "re: Comment Script: Error" Posted: @ 8:02 pm on Oct 09 2007    
Member #: 421
Rank: User - (6)
Since: 09/27/07
Posts: 6
From: Reading, MA

Ah! Ok, I've fixed that error (I figured it was something my tired eyes simply overlooked) but now I'm getting this one:

"Parse error: parse error, unexpected '}' in /hsphere/local/ home/chinako/ch inako.nu/bswl/c omments.php on line 23"

Besides getting this error, the comments system has somehow blocked the first entry to show up on this page, so I get this second entry with an error instead. I have about 52 entries on this one PHP page which I would like individual comments for, but hopefully the code won't block out every entry with the same code (I'm only using two entries right now to determine if they can hold individual comments or not)!




    Viewed: 12,659 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Comment Script: Error" Posted: @ 9:31 pm on Oct 09 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

You'll have to post the code above and below line 23 in order to help resolve that issue. Once that is fixed, then we'll see if the comment script is responding appropriately.




-bs0d | AllSyntax.com

    Viewed: 12,653 Times | Reply to This | To top
  This user is offline  chinako
  Subject: "re: Comment Script: Error" Posted: @ 11:11 pm on Oct 09 2007    
Member #: 421
Rank: User - (6)
Since: 09/27/07
Posts: 6
From: Reading, MA


Code:

<?

//connect to your database

//query comments for this page of this article
$inf = "SELECT * FROM 'chinako_comme nts' WHERE page = '".strip slashes($_SERVE R['REQUEST_URI '])."' ORDER BY time DESC";
$info = mysql_query($in f);
if(!$info) die (mysql_error()) ;

$info_rows = mysql_num_rows ($info);
if($info_rows > 0) {
echo '<h5>Com ments:</h5&g t;';
echo '<table width="95 %">';

while($info2 = mysql_fetch_obj ect($info)) {
echo '<tr>';
echo '<td>&q uot;'.stripsla shes ($info2->sub ject).'" by: <a href="'. $info2->cont act.'"&g t;'.stripslash es($info2->u sername).'< /a></td&g t;<td>< ;div align="ri ght"> @ '.date('h:i:s a', $info2->time ).' on '.$info2->d ate.'</div& gt;</td> ';
echo '</tr>&l t;tr>';
echo '<td colspan=" 2">'. stripslashes($i nfo2->commen t).'</td> ;';
echo '</tr>' ;}
}//end while
echo '</table> ;';
echo '<hr width="95 %" noshade>';< br /> } else echo 'No comments for this page. Feel free to be the first <br>';
if(isset($_POST ('submit})) {



From line 1 to 25. Please help if you can. Let me know if you need more. Thank you!




    Viewed: 12,650 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Comment Script: Error" Posted: @ 2:00 pm on Oct 10 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Easy!

Line 25. if(isset($_POST ('submit})) {

should be: if(isset($_POST ['submit'])) {




-bs0d | AllSyntax.com

    Viewed: 12,632 Times | Reply to This | To top
  This user is offline  chinako
  Subject: "re: Comment Script: Error" Posted: @ 6:37 pm on Oct 10 2007    
Member #: 421
Rank: User - (6)
Since: 09/27/07
Posts: 6
From: Reading, MA

Ok, I fixed that as well, but I'm still getting the same error (only now for line 24). Here is the entire code. I had to hand-type it from this site to my text editor as my Copy/Paste wasn't working for some reason. I'm sure there are some more errors in there, but I've looked it over three times today and have found none. Maybe I'm overlooking something?


Code:

<?

//connect to your database

//query comments for this page of this article
$inf = "SELECT * FROM 'chinako_comme nts' WHERE page = '".strip slashes($_SERVE R['REQUEST_URI '])."' ORDER BY time DESC";
$info = mysql_query($in f);
if(!$info) die (mysql_error()) ;

$info_rows = mysql_num_rows ($info);
if($info_rows > 0) {
echo '<h5>Com ments:</h5&g t;';
echo '<table width="95 %">';

while($info2 = mysql_fetch_obj ect($info)) {
echo '<tr>';
echo '<td>&q uot;'.stripsla shes ($info2->sub ject).'" by: <a href="'. $info2->cont act.'"&g t;'.stripslash es($info2->u sername).'< /a></td&g t;<td>< ;div align="ri ght"> @ '.date('h:i:s a', $info2->time ).' on '.$info2->d ate.'</div& gt;</td> ';
echo '</tr>&l t;tr>';
echo '<td colspan=" 2">'. stripslashes($i nfo2->commen t).'</td> ;';
echo '</tr>' ;}
}//end while
echo '</table> ;';
echo '<hr width="95 %" noshade>';< br /> } else echo 'No comments for this page. Feel free to be the first <br>';
if(isset($_POST ['submit'])) {
if(!addslashes ($_POST ['username']) ) die('<u> ERROR</u> you must enter a username to add a comment.');
if(!addslashes ($_POST ['contact'])) die('<u> ERROR:</u> ; enter contact method in contact field.');
if(!addslashes ($_POST ['subject'])) die('<u> ERROR:</u> ; enter a subject to your comment);
if(!addslashes ($_POST ['comment'])) die('<u> ERROR:</u> ; cannot add comment if you do not enter one!?);

//this is for a valid contact
if(substr($_PO ST ['contact'],0 ,7) != 'mailto:' && !strstr($_POST ['contact'], '//')) {
if(strstr ($_POST['conta ct'],'@')) $_POST['conta ct'] = "http:// ".$_POST[ 'contact'].&q uot;";
} //end valid contact

//try to prevent multiple posts and flooding...
$c = "SELECT * from 'comments' WHERE ip = '". $_SERVER['REMO TE_ADDR'].&qu ot;'"; $c2 = mysql_query($c) ;
while($c3 = mysql_fetch_obj ect($c2)) {
$difference = time() - $c3->time; if($difference < 300) die('<u> ALERT:</u> ; '.$c3->user name.', You have already commented earlier; if you have a question, try the forum!<br> ;');
} //end while

//add comment
$q ="INSERT INTO 'comments' (article_id, page, date, time, username, ip, contact, subject, comment) VALUES ('". $_GET['id']. "', '".$_POS T['page'].&q uot;', '".$_POS T['date'].&q uot;', '".$_POS T['time'].&q uot;', '".addsl ashes(htmlspeci alchars($_POST[ 'username'])) ."', '".$_SER VER['REMOTE_AD DR']."' , '".addsl ashes(htmlspeci alchars($_POST[ 'contact'])). "', '".addsl ashes(htmlspeci alchars($_POST[ 'subject'])). "', '".addsl ashes(htmlspeci alchars(n12br($ _POST['comment '])))." ')";

$q2 = mysql_query($q) ;
if(!$q2) die(mysql_error ());

//refresh page so they can see new comment
header('Locati on: http://' . $_SERVER['HTTP _HOST'] . $_POST['page' ] . "#comment s");

} else { //display form
?>
<form name="com ments" action="& lt;? $_SERVER['PHP_ SELF']; ?>" method="p ost">< br />
<input type="hid den" name="pag e" value="&l t;? echo ($_SERVER['REQ UEST_URI']); ?>"> ;
<input type="hid den" name="dat e" value="&l t;? echo (date("F j, Y.")); ?>"> ;
<input type="hid den" name="tim e" value="&l t;? echo (time()); ?>"> ;

<table width="90 %" border="0 " cellspacing=&q uot;0" cellpadding=&q uot;0"> ;
<tr>
<td>< div align="ri ght">U sername: </div>< ;/td>
<td>< input name="use rname" type="tex t" size="30 " value="& quot;></t d>
</tr>
<tr>
<td>< div align="ri ght">C ontact: </div>< ;/td>
<td>< input type="tex t" name="con tact" size="30 " value="& quot;> <i>(email or url)</i>& lt;/td>
</tr>
<td>< div align="ri ght">S ubject: </div>< ;/td>
<td>< input type="tex t" name="sub ject" size="30 " value="& quot;></t d>
</tr>
<tr>
<td>< div align="ri ght">C omment: </div>< ;/td>
<td>< textarea name="com ment" cols="45 " rows="5& quot; wrap="VIR TUAL"> </textarea&g t;</td> </tr>
<tr>
<td>< /td>
<td colspan=" 2">< ;input type="res et" value="Re set Fields"&g t;
<input type="sub mit" name="sub mit" value="Ad d Comment"& gt;</td>< br /> </tr>
</table>
</form>< br /> <?
} //end else
?>




    Viewed: 12,625 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Comment Script: Error" Posted: @ 4:28 pm on Oct 11 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Looks like line 24 is: echo '</tr>' ;} . Remove the } .




-bs0d | AllSyntax.com

    Viewed: 12,579 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank