lord_havoc
03-25-2007, 09:34 PM
Okay, I had the help of someone write this code for me. Now I am having trouble with it. I have no experience whatsoever with PHP at all. So anything you can tell me would be be greatly appreciated
It gives me these errors on the page the script is at.
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in /home/cyanidep/public_html/blog/config.php on line 52
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'cyanidep'@'localhost' (using password: NO) in /home/cyanidep/public_html/blog/config.php on line 53
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/cyanidep/public_html/blog/config.php on line 53
Warning: mysql_query() [function.mysql-query]: Access denied for user 'cyanidep'@'localhost' (using password: NO) in /home/cyanidep/public_html/index.php on line 10
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/cyanidep/public_html/index.php on line 10
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/cyanidep/public_html/index.php on line 12
The following is config.php
<?php
#### DB Connection Settings ####
$DBserver = "www.hostmonster.com"; //server the mysql database is on
$DBuser = "xxxxx"; //username for MySQL database
$DBpass = "xxxxx"; //password for above mentioned user
$DB = "xxxxxx"; //db for news
#### DB Table Settings ####
$newsTable = "news"; //table in db the news is in
$commentsTable = "comments"; //table in db the comments are in
#### HTML Template Settings ####
/* header section up until the main content */
$head = <<<HERE
<html>
<head>
<script language="JavaScript" type="text/javascript" src="wysiwyg.js"></script>
<script type="text/javascript">
function confDel() {
if (confirm("By deleting this post, you also delete all comments for it. Are you sure you wish to continue?")) {
return true;
}
else {
return false;
}
}
</script>
<title>Web Administration</title>
<body>
HERE;
/* footer section of the page */
$footer = <<<HERE
</body>
</html>
HERE;
/* What msg to disply if no results are found in the db */
$noResults = "<b>There are no results in the database. Please try again later.</b>";
mysql_connect($DBserver, $DBuser, $DBpass);
mysql_select_db($DB);
?>
index.php is as follows
<?php include("tempnav.php") ?>
<p>
<!--PHP Generated Results-->
<?php
include("http://www.cyanideperfection.net/blog/config.php");
$results = mysql_query("SELECT * FROM `$newsTable` ORDER BY `id` DESC");
if (mysql_num_rows($results) < 1) {
echo $noResults;
}
else {
while ($qry = mysql_fetch_array($results)) {
echo $qry['date']."<BR>".$qry['news']."<BR><BR>";
$comments = mysql_query("SELECT * FROM `$commentsTable` WHERE `newsID`='$qry[id]'");
$cCount = mysql_num_rows($comments);
echo '<a href="http://www.cyanideperfection.net/blog/comments.php?id='.$qry['id'].'" onclick="commentsWin(this.href); return false;">Comments ('.$cCount.')</a><br><br><br>';
}
}
?>
</p>
</div>
</div>
</body>
</html>
Hopefully, someone can help me with this. I really need this blog set up soon.
Thanks.
It gives me these errors on the page the script is at.
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in /home/cyanidep/public_html/blog/config.php on line 52
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'cyanidep'@'localhost' (using password: NO) in /home/cyanidep/public_html/blog/config.php on line 53
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/cyanidep/public_html/blog/config.php on line 53
Warning: mysql_query() [function.mysql-query]: Access denied for user 'cyanidep'@'localhost' (using password: NO) in /home/cyanidep/public_html/index.php on line 10
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/cyanidep/public_html/index.php on line 10
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/cyanidep/public_html/index.php on line 12
The following is config.php
<?php
#### DB Connection Settings ####
$DBserver = "www.hostmonster.com"; //server the mysql database is on
$DBuser = "xxxxx"; //username for MySQL database
$DBpass = "xxxxx"; //password for above mentioned user
$DB = "xxxxxx"; //db for news
#### DB Table Settings ####
$newsTable = "news"; //table in db the news is in
$commentsTable = "comments"; //table in db the comments are in
#### HTML Template Settings ####
/* header section up until the main content */
$head = <<<HERE
<html>
<head>
<script language="JavaScript" type="text/javascript" src="wysiwyg.js"></script>
<script type="text/javascript">
function confDel() {
if (confirm("By deleting this post, you also delete all comments for it. Are you sure you wish to continue?")) {
return true;
}
else {
return false;
}
}
</script>
<title>Web Administration</title>
<body>
HERE;
/* footer section of the page */
$footer = <<<HERE
</body>
</html>
HERE;
/* What msg to disply if no results are found in the db */
$noResults = "<b>There are no results in the database. Please try again later.</b>";
mysql_connect($DBserver, $DBuser, $DBpass);
mysql_select_db($DB);
?>
index.php is as follows
<?php include("tempnav.php") ?>
<p>
<!--PHP Generated Results-->
<?php
include("http://www.cyanideperfection.net/blog/config.php");
$results = mysql_query("SELECT * FROM `$newsTable` ORDER BY `id` DESC");
if (mysql_num_rows($results) < 1) {
echo $noResults;
}
else {
while ($qry = mysql_fetch_array($results)) {
echo $qry['date']."<BR>".$qry['news']."<BR><BR>";
$comments = mysql_query("SELECT * FROM `$commentsTable` WHERE `newsID`='$qry[id]'");
$cCount = mysql_num_rows($comments);
echo '<a href="http://www.cyanideperfection.net/blog/comments.php?id='.$qry['id'].'" onclick="commentsWin(this.href); return false;">Comments ('.$cCount.')</a><br><br><br>';
}
}
?>
</p>
</div>
</div>
</body>
</html>
Hopefully, someone can help me with this. I really need this blog set up soon.
Thanks.