100 Web Space
http://forum.100webspace.com/

PHP and Connecting problem, please HELP
http://forum.100webspace.com/viewtopic.php?f=5&t=4878
Page 1 of 1

Author:  krahar [ Fri Sep 08, 2006 7:03 pm ]
Post subject:  PHP and Connecting problem, please HELP

Hi, i have some problem.
My script is:
<? php
$link = mysql_connect('localhost', 'user', 'pass');
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('database name');
$a='hello';
echo $a;
?>
But i see this wrong:
Parse error: parse error in /home/www/krahar.100webspace.net/index.php on line 2.
Please help. Thanks

Author:  krahar [ Wed Jan 24, 2007 12:20 pm ]
Post subject: 

PsychoticDude85 wrote:
"<? php" should be "<?php", and I don't think you can connect to the 100ws mysql databases with 'localhost' anyway. Look in the MySQL section of your control panel for the correct setting. (I am assuming you have set the username and password in the real script and just removed them to paste here...).

More information on connecting: http://php.net/mysql_connect


Thank you !

Author:  scorpian8867 [ Thu Jan 25, 2007 4:02 am ]
Post subject: 

Also, a more efficient way to connect would be something like this:

Code:
$link = mysql_connect('localhost', 'user', 'pass') or die("Connection Failed: " . mysql_error());


That's a little easier then using a separate if loop. ;)

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/