Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Support
  • Code University
  • Comment Script
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
  • Pages:
  • 1
  • 2
Comment Script
Tweet Topic Started: Mar 27 2009, 12:04 PM (791 Views)
PD.Phoenix Mar 27 2009, 12:04 PM Post #1
Member Avatar
Kokuhyou no Tentei

Posts:
326
Group:
Member
Member
#602
Joined:
Aug 15, 2008
Coding language
HTML/CSS
Ok... I've been working on a comment script for my website but I just get a PHP error...

I keep getting this...

Error
 
Warning: mysql_connect() [function.mysql-connect]: Access denied for user '******'@'localhost' (using password: YES) in /home/a3687828/public_html/cbmodel/inc_rate.php on line 13


I've blocked out my info.

But anyways, this is line 13 where it says the error is...

Code:
 
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());


I'm pretty sure I've set up the DB and every correctly but I cant figure his out...
Phoenix Designz is now open
Looking for staff and classers PM me here or on PD if interested.

Want to win some easy money? Enter Phoenix Designz tournaments. Learn more here ->> click


Posted Image
| My dA | Vote PD Top 100 |
Offline Profile Goto Top
 
HolySavior Mar 27 2009, 03:38 PM Post #2
Member Avatar
Modifying The World Around You

Posts:
2,488
Group:
Distinguished Coder
Member
#7
Joined:
Jul 2, 2008
Coding language
Everything
what is lines 10-14.. normally when they give you a line its usually a line or possibly two ahead or behind. the actual line numbers. its weird yes. but its not always on that 1 particular line.
Offline Profile Goto Top
 
PD.Phoenix Mar 27 2009, 04:32 PM Post #3
Member Avatar
Kokuhyou no Tentei

Posts:
326
Group:
Member
Member
#602
Joined:
Aug 15, 2008
Coding language
HTML/CSS
Code:
 
<?
//Please set the following variables for your mysql database:
$db_hostname = "localhost";
$db_username = "username removed";
$db_pass = "password removed";
$db_name = "database name removed";



/*MYSQL DATABASE CONNECTION/ TRACKING FUNCTIONS
--------------------------------------*/
// connect to database
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);


Lines 1-14
Phoenix Designz is now open
Looking for staff and classers PM me here or on PD if interested.

Want to win some easy money? Enter Phoenix Designz tournaments. Learn more here ->> click


Posted Image
| My dA | Vote PD Top 100 |
Offline Profile Goto Top
 
HolySavior Mar 27 2009, 06:34 PM Post #4
Member Avatar
Modifying The World Around You

Posts:
2,488
Group:
Distinguished Coder
Member
#7
Joined:
Jul 2, 2008
Coding language
Everything
have you tried using double quotes instead of single ones?
Offline Profile Goto Top
 
PD.Phoenix Mar 27 2009, 07:43 PM Post #5
Member Avatar
Kokuhyou no Tentei

Posts:
326
Group:
Member
Member
#602
Joined:
Aug 15, 2008
Coding language
HTML/CSS
Didn't do anything. Getting the same error...
Phoenix Designz is now open
Looking for staff and classers PM me here or on PD if interested.

Want to win some easy money? Enter Phoenix Designz tournaments. Learn more here ->> click


Posted Image
| My dA | Vote PD Top 100 |
Offline Profile Goto Top
 
Kevin Mar 27 2009, 08:13 PM Post #6
Member Avatar


Posts:
700
Group:
Former Staff
Member
#8
Joined:
Jul 2, 2008
Coding language
HTML/CSS
Are you totally sure that you're using the right username, and password, and it's all set up correctly?

I know it sounds stupid, but I have had made mistakes where I put the username as something like kevim instead of kevin, or something like that. As far as I can tell, there's nothing wrong with your code, so the only other cause I can think of would be a typo or mistake.
Posted Image
Offline Profile Goto Top
 
PD.Phoenix Mar 27 2009, 09:36 PM Post #7
Member Avatar
Kokuhyou no Tentei

Posts:
326
Group:
Member
Member
#602
Joined:
Aug 15, 2008
Coding language
HTML/CSS
><
><
><
><
><


FUCK! ><

I entered the host and username wrong >>

Thanx Kevin... sorry guys D:
Phoenix Designz is now open
Looking for staff and classers PM me here or on PD if interested.

Want to win some easy money? Enter Phoenix Designz tournaments. Learn more here ->> click


Posted Image
| My dA | Vote PD Top 100 |
Offline Profile Goto Top
 
HolySavior Mar 27 2009, 09:56 PM Post #8
Member Avatar
Modifying The World Around You

Posts:
2,488
Group:
Distinguished Coder
Member
#7
Joined:
Jul 2, 2008
Coding language
Everything
its ok i have done that too. :P
Offline Profile Goto Top
 
PD.Phoenix Mar 28 2009, 01:05 AM Post #9
Member Avatar
Kokuhyou no Tentei

Posts:
326
Group:
Member
Member
#602
Joined:
Aug 15, 2008
Coding language
HTML/CSS
I have another issue...

The redirect of the submission script doesn't redirect back to the page you posted a comment on...

any help?

Code:
 

<?php

$db_hostname = "Removed";
$db_username = "Removed";
$db_pass = "Removed";
$db_name = "Removed";



$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);


$tuturl = $_POST["tuturl"];
$tutid2 = $_POST["tutid2"];
$name = $_POST["name"];
$url = $_POST["url"];
$email = $_POST["email"];
$message = $_POST["message"];
$sendcomment = mysql_query("INSERT INTO comments SET tutorialid='$tutid2', name='$name', url='$url', email='$email', comment='$message', date=now()");
if($sendcomment){
//header("Location: $tuturl");
echo "<h1>Submission Successful</h1>";
echo "Your comment has been submitted. You will now be redirected back to the last page you visited. Thanks!";
echo "<meta http-equiv='refresh' content='2;URL=$tuturl'>";
} else {
echo "There was an error with the submission. ";
}

?>
Edited by PD.Phoenix, Mar 28 2009, 01:14 AM.
Phoenix Designz is now open
Looking for staff and classers PM me here or on PD if interested.

Want to win some easy money? Enter Phoenix Designz tournaments. Learn more here ->> click


Posted Image
| My dA | Vote PD Top 100 |
Offline Profile Goto Top
 
Kevin Mar 28 2009, 09:24 AM Post #10
Member Avatar


Posts:
700
Group:
Former Staff
Member
#8
Joined:
Jul 2, 2008
Coding language
HTML/CSS
Does it give you an error, or just not redirect? Give this a try:

Code:
 
<?php

$db_hostname = "Removed";
$db_username = "Removed";
$db_pass = "Removed";
$db_name = "Removed";



$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);


$tuturl = $_POST["tuturl"];
$tutid2 = $_POST["tutid2"];
$name = $_POST["name"];
$url = $_POST["url"];
$email = $_POST["email"];
$message = $_POST["message"];
$sendcomment = mysql_query("INSERT INTO comments SET tutorialid='$tutid2', name='$name', url='$url', email='$email', comment='$message', date=now()");
if($sendcomment){
//header("Location: $tuturl");
echo "<h1>Submission Successful</h1>";
echo "Your comment has been submitted. You will now be redirected back to the last page you visited. Thanks!";
echo "<meta http-equiv='refresh' content='2;URL='".$tuturl."'>";
} else {
echo "There was an error with the submission. ";
}

?>


What I did is change the line where you had the meta refresh. I've always had issues when embedding variables within quotes...
Posted Image
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
ZetaBoards - Free Forum Hosting
Free Forums with no limits on posts or members.
Learn More · Sign-up for Free
Go to Next Page
« Previous Topic · Code University · Next Topic »
Locked Topic
  • Pages:
  • 1
  • 2

Track Topic · E-mail Topic Time: 7:48 PM Jul 10
Hosted for free by ZetaBoards · Privacy Policy