PDA

View Full Version : PHP/MYSQL issues


bluemicrobyte
12-21-2005, 6:05 PM
So I'm trying to install a comment script that lets users post comments on a web page. I think I've set up the MySQL database correctly, but then again I've never done it before.

Heres the page with the problem:

http://www.microbyteproductions.com/movies/chitchat_mainpage2.php

Heres the error:

Warning: mysql_query(): Access denied for user 'microbyt'@'localhost' (using password: NO) in /home/microbyt/public_html/movies/chitchat_mainpage2.php on line 211

If you need more information I can provide it, but maybe from that eror someone can tell me that theres something simple I did wrong :P

Black.Ice
12-21-2005, 7:00 PM
Haha, the error message is pretty straight forward. Access was denied for you to access the database. Is your username right? What about your password? Check the database permissions; are you allowed to do whatever you're trying to do?

Double check those.

bluemicrobyte
12-21-2005, 8:48 PM
Alright, well whatever I did it's working now. But I have a new problem: can I modify this script so that the comments are displayed with the newest comments on top?

function showComms($id,$path) {




include("com/db.php");


$catid = $id;
$sql = mysql_query("SELECT * FROM ".$so_prefix."_main WHERE catid='".$catid."' ORDER BY id ");
while ($irow = mysql_fetch_row($sql)) {
echo "
<div class='sayopcontainer'>
<div class='sayopspacer'>&nbsp;</div>
<div class='sayopufloat'>By $irow[3] &nbsp;&nbsp;&nbsp;&nbsp; $irow[4]<br /></div>
<div class='sayopfloat'>$irow[5]<br /></div>
<div class='sayopdfloat'>posted at $irow[6]<br /></div>
<div class='sayopspacer'>&nbsp;</div>
</div>
";
}


$s = mysql_query("SELECT * FROM ".$so_prefix."_obj WHERE catid='".$catid."' ");
$o_name = mysql_fetch_row($s);
$obj_name = $o_name[1];

$p = $path;

echo "
<div style='sayopfloat: left;width: 35%; background-color: ; border-top: 0px; border-bottom: 1px groove #333; padding: 5px;
margin: 0px auto; text-align: left;'>
<form name='f1' action='$p/com/add_entry.php' method='post'>
<input type='hidden' name='obj_name' value='$obj_name' />
<input type='hidden' name='catid' value='$catid' />
<div class='sayoprow'>
Name: <input type='text' size='25' name='author' />
</div>
";
echo "
<div class='sayoprow'>
Email: <input type='text' size='25' name='email' /><span class='sayopsmall'>(optional)</span>
</div>

";
echo "
<div class='sayoprow'>
<span class='sayoplabel'>Comments:</span><span
class='sayopformw'>
<textarea name='comment' cols='32' rows='8'></textarea>
</span>
</div>
<div class='sayoprow'>
<input type='submit' name='Add' value='Sayit' />
</div>
<div class='sayopspacer' style='text-align: right'>
<a href='http://www.devplant.com/sayop' class='sl'>Powered by SayOp</a>
</div>
</form>
</div>
";


}

WeekendLazyness
12-22-2005, 5:58 PM
Change this line
$sql = mysql_query("SELECT * FROM ".$so_prefix."_main WHERE catid='".$catid."' ORDER BY id ");
to:
$sql = mysql_query("SELECT * FROM ".$so_prefix."_main WHERE catid='".$catid."' ORDER BY id DESC");

bluemicrobyte
12-22-2005, 9:04 PM
Huzzah! Yee hath proven yourself worthy! For this, I hereby dub thee Sir Lazalot for thee uber weekend lazypowers.

And in plain english: thankss!

WeekendLazyness
12-22-2005, 10:28 PM
Huzzah! Yee hath proven yourself worthy! For this, I hereby dub thee Sir Lazalot for thee uber weekend lazypowers.

And in plain english: thankss!Thank TimP. He showed me first.
I also wasn't aware I had to prove myself worthy.