It is currently Thu Mar 28, 2024 9:55 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: PHP and Connecting problem, please HELP
PostPosted: Fri Sep 08, 2006 7:03 pm 
Noobie
Noobie

Joined: Fri Sep 08, 2006 6:29 pm
Posts: 2
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 24, 2007 12:20 pm 
Noobie
Noobie

Joined: Fri Sep 08, 2006 6:29 pm
Posts: 2
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 !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 25, 2007 4:02 am 
Experienced
Experienced

Joined: Fri Apr 28, 2006 9:49 pm
Posts: 50
Location: Texas
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. ;)

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ]  Moderators: fhmagic, KJ, Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
100WebSpace © 2011