Page 1 of 1
Help!
Posted: Sun Apr 06, 2008 8:28 pm
by masterphp
I have wroted a php program handling "Message Board" system(total including 7 php files), but when I run from Apache server, some of the files always show me the following error, I have no idea how to debug this, can someone give me any help or hint? thanks!
I have Apache with PHP+MySQL envirnoment
following is my database information:
<?php
$DBHOST="
http://localhost/htdocs";
$DBUSER="root";
$DBPWD="12345";
$DBNAME="guestbook";
?>
*************************error messages I got**************************
1.Parse error: syntax error, unexpected ',' in C:\AppServ\www\htdocs\search.php on line 64
2.Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'http' (11001) in C:\AppServ\www\htdocs\replylist.php on line 9
3.Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\AppServ\www\htdocs\replylist.php on line 10
4.Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in C:\AppServ\www\htdocs\replylist.php on line 10
5.Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\AppServ\www\htdocs\replylist.php on line 12
6.Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\htdocs\replylist.php on line 16
7.Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in C:\AppServ\www\htdocs\replylist.php on line 21
Re: Help!
Posted: Sun Apr 06, 2008 9:08 pm
by Christopher
The host should just be 'localhost'.
Re: Help!
Posted: Sun Apr 06, 2008 10:47 pm
by masterphp
Thanks arborint! but after I changed to the following setting, I sitll got the same error! so why is that? I have tired following both ways! can anyone give me a help?
<?php
$DBHOST="localhost";
$DBUSER="root";
$DBPWD="12345";
$DBNAME="guestbook";
?>
<?php
$DBHOST="
http://localhost";
$DBUSER="root";
$DBPWD="12345";
$DBNAME="guestbook";
?>
Re: Help!
Posted: Mon Apr 07, 2008 12:23 am
by Christopher
Show the code that is doing the connection. Are you sure all the information is correct?
Re: Help!
Posted: Mon Apr 07, 2008 10:02 am
by Jonah Bron
Post what it says on line 64 in "search.php". Also, relevant post titles are always best

Re: Help!
Posted: Mon Apr 07, 2008 10:34 am
by pickle
Re: Help!
Posted: Mon Apr 07, 2008 11:04 am
by Mordred
Actually I think that "Why?" is the best answer to a "Help!" thread - I mean, if the poster hasn't bothered to write a short description of his problem, why should anyone bother to answer? The mere fact that someone
does is a sign of the greatness of this community

Re: Help!
Posted: Mon Apr 07, 2008 11:21 am
by masterphp
The following is my "search.php" and "replylist.php" code, the error messages I got are pretty much related to those two php files.
Code: Select all
<!--sys_conf.inc:------------------------------>//This is just my sys_conf.inc file that I include in the search.php file
<?php
$DBHOST="http://localhost";
$DBUSER="root";
$DBPWD="12345";
$DBNAME="guestbook";
?>
<!--search.php:--------------------->
<?php
require_once("sys_conf.inc");
function search($keyword,$content)
{
$count=count($content);
$j=0;
$ArrSearch=array();
for ($i=0;$i<$count;$i++)
{
if (ereg($keyword,$content[$i]))
{
$ArrSearch[$j]=str_replace($keyword,"<font color=red><b>$keyword</b></font>",$content[$i]);
$j++;
}
}
return $ArrSearch;
}
function searchid($keyword,$rid,$content)
{
$count=count($content);
$j=0;
$Arrid=array();
for ($i=0;$i<$count;$i++)
{
if (ereg($keyword,$content[$i]))
{
$Arrid[$j]=$rid[$i];
$j++;
}
}
return $Arrid;
}
$one_page_line=10;
$content=array();
$id=array();
$ArrSearch=array();
$Arrid=array();
$link_id=mysql_connect($DBHOST,$DBUSER,$DBPWD);
mysql_select_db($DBNAME);
$str="select rid,content from guestbook";
$result=mysql_query($str,$link_id);
$i=0;
while(list($rid,$con)=mysql_fetch_row($result))
{
$content[$i]=$con;
$id[$i]=$rid;
$i++;
}
mysql_close($link_id);
if (isset($_POST["search"]) and isset($_POST["keyword"]) and $_POST["keyword"]!="")
{
$ArrSearch=search($_POST["keyword"],$content);
$Arrid=searchid($_POST["keyword"].,$id,$content);
}
else
{
$ArrSearch=$content;
$Arrid=$id;
}
//print_r($ArrSearch);
//print_r($Arrid);
$count =count($ArrSearch);
?>
<!--replylist.php:--------------------->
<?php
require_once("sys_conf.inc");
//Initial
$one_page_line=10; //Max_Page
$reply_content=array();
$link_id=mysql_connect($DBHOST,$DBUSER,$DBPWD);
mysql_select_db($DBNAME);
$str="select content from reply where bookid =".$_GET["recordid"];
$result=mysql_query($str,$link_id);
$i=0;
while(list($con)=mysql_fetch_row($result))
{
$reply_content[$i]=$con;
$i++;
}
mysql_close($link_id);
$count =count($reply_content);
?>
<html>
<head>
<title>Look for reply</title>
</head>
<body>
<?php include "head.html"?>
<table width="68%" border="0">
<tr>
<td>
<?php
$int_page_count=$count;
$int_page_num=ceil($int_page_count/$one_page_line);
echo "<font color=#CC33FF>page separate:";
for ($i=1;$i<=$int_page_num;$i++)
{
echo "<a href=booklist.php?recordid=".$_GET["recordid"]."&page=$i>".$i."</a> ";
}
echo "</font>";
?>
</td>
<td><p align=right>Total<font color=red><?echo "$count"?></font>Messages</p></td>
</tr>
</table>
<table width="68%" border="0" align="center">
<?
if (!isset($page) or $page=="")
$page=1;
$text="";
$begin_line=$int_page_count-($page-1)*$one_page_line;
if ($begin_line<$one_page_line)
$one_page_line=$begin_line;
for ($j=$begin_line;$j>($begin_line-$one_page_line);$j--)
{
print_r ($reply_content[$j-1]);
}
?>
</table>
<p align=center><a href="#" onclick=history.back()>Return</a></p>
</body>
</html>
Re: Help!
Posted: Mon Apr 07, 2008 2:37 pm
by Mordred
masterphp wrote:... the error messages I got are pretty much related to those two php files.
Well, have you tried the same solutions?

Re: Help!
Posted: Mon Apr 07, 2008 8:10 pm
by califdon
masterphp wrote:Code: Select all
Parse error: syntax error, unexpected ',' in C:\AppServ\www\htdocs\search.php on line 64
I'd look at line 64
masterphp wrote:Code: Select all
$Arrid=searchid($_POST["keyword"].,$id,$content);
Re: Help!
Posted: Mon Apr 07, 2008 8:42 pm
by earcaraxe
I'm new here, and I hope I'm not stepping on Califdon's toes, but there shouldn't be a period after your $_POST["keyword"] on line 64. Just a comma. I always hate it when I get random punctuation in that's messing up my syntax, and it's often hard to find. Get rid of that and it'll eliminate that first error.
Also take out the "
http://localhost" and make it just "localhost". That should help a bit.
Re: Help!
Posted: Thu Apr 10, 2008 11:27 pm
by masterphp
Thanks a lot earcaraxe! it works now, yeah, it is hard to see that small error, thanks for your help.