PDA

View Full Version : PhP help



Rafiki
27-03-2008, 08:05 PM
what goes in these?
<?
$host = "localhost";
$dbuser = "Database User";
$dbpwd = "Database Password";
$db = "Database Name";
$connect = mysql_pconnect($host, $dbuser, $dbpwd);
if(!$connect)
echo("Could not connect to database...");
else
$select = mysql_select_db($db);
?>

Moved by Hitman (Forum Moderator) from Designing & Development: Please post in the correct forum next time, thanks. :)

Decode
27-03-2008, 08:17 PM
You need to setup a database, go to your hosts, MyPhpAdmin page and then create a new database with the name Database, then create a user with the name User and password of (what ever you want). And give the user full access rights to the databse.

Then your php should be.



<?
$host = "localhost";
$dbuser = "User";
$dbpwd = "YourPassword!!";
$db = "Database";
$connect = mysql_pconnect($host, $dbuser, $dbpwd);
if(!$connect)
echo("Could not connect to database...");
else
$select = mysql_select_db($db);
?>

Hitman
27-03-2008, 08:19 PM
Also, shouldn't the if statement be like this:


<?
$host = "localhost";
$dbuser = "Database User";
$dbpwd = "Database Password";
$db = "Database Name";
$connect = mysql_pconnect($host, $dbuser, $dbpwd);
if(!$connect) {
echo("Could not connect to database...");
} else {
$select = mysql_select_db($db);
}
?>

Rafiki
27-03-2008, 08:20 PM
it says Parse error: syntax error, unexpected '=' in /home/icehabbo/public_html/config.php on line 2

<?
$host&nbsp;=&nbsp;"localhost";
$dbuser&nbsp;=&nbsp;"icehabbo_david";
$dbpwd&nbsp;=&nbsp;"for security reasons";
$db&nbsp;=&nbsp;"icehabbo_user";
$connect&nbsp;=&nbsp;mysql_pconnect($host,&nbsp;$dbuser,&nbsp;$dbpwd);
if(!$connect)
echo("Could&nbsp;not&nbsp;connect&nbsp;to&nbsp;database...");
else
$select&nbsp;=&nbsp;mysql_select_db($db);
?>

Hitman
27-03-2008, 08:21 PM
Can you post the code you tried please?

Robbie
27-03-2008, 08:22 PM
Are you using Hitmans code?

Rafiki
27-03-2008, 08:23 PM
<?
$host&nbsp;=&nbsp;"localhost";
$dbuser&nbsp;=&nbsp;"icehabbo_david";
$dbpwd&nbsp;=&nbsp;"*removed*";
$db&nbsp;=&nbsp;"icehabbo_user";
$connect&nbsp;=&nbsp;mysql_pconnect($host,&nbsp;$dbuser,&nbsp;$dbpwd);
if(!$connect)
echo("Could&nbsp;not&nbsp;connect&nbsp;to&nbsp;database...");
else
$select&nbsp;=&nbsp;mysql_select_db($db);
?> there is code :S

Hitman
27-03-2008, 08:24 PM
<?
$host&nbsp;=&nbsp;"localhost";
$dbuser&nbsp;=&nbsp;"icehabbo_david";
$dbpwd&nbsp;=&nbsp;"*removed*";
$db&nbsp;=&nbsp;"icehabbo_user";
$connect&nbsp;=&nbsp;mysql_pconnect($host,&nbsp;$dbuser,&nbsp;$dbpwd);
if(!$connect)
echo("Could&nbsp;not&nbsp;connect&nbsp;to&nbsp;database...");
else
$select&nbsp;=&nbsp;mysql_select_db($db);
?> there is code :S
I removed the password for you, don't want anybody getting into your cP. :P

Try the code I gave.

Rafiki
27-03-2008, 08:26 PM
http://icehabbo.com/ thts what it says now :S

Robbie
27-03-2008, 08:26 PM
Why have you got loads of spaces (&nbsp;)? :S

Rafiki
27-03-2008, 08:31 PM
i dont now still not working :S

Robbie
27-03-2008, 08:33 PM
Also, shouldn't the if statement be like this:


<?
$host = "localhost";
$dbuser = "Database User";
$dbpwd = "Database Password";
$db = "Database Name";
$connect = mysql_pconnect($host, $dbuser, $dbpwd);
if(!$connect) {
echo("Could not connect to database...");
} else {
$select = mysql_select_db($db);
}
?>

That should be fine, I don't get it, what editor are you using, Notepad?

Rafiki
27-03-2008, 08:34 PM
No dreamweaver :S

Robbie
27-03-2008, 08:39 PM
Are you putting it in the code section and not the actual page? Try notepad.

Rafiki
27-03-2008, 08:42 PM
d.w hitman helping me :D

Want to hide these adverts? Register an account for free!