Some one help me!

intertec

New Member
Messages
946
Reaction score
0
Points
0
I am going through a php tutorial! I have finshed it but I'm confused for one part!


The part where is says yourdatabase! What do I put in there! I know it syas yourdatabase but when I do that it comes with this error when I run it!

syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/intertek/public_html/config.php on line 3


<?php

$l = mysql_connect ( "localhost" , "yourmysqlUser" , "password" ) or die("Error connecting: <br><br>".mysql_error());
mysql_select_db( "yourdatabase" ) or die("Error getting db: <br><br>".mysql_error());

?>


Some body help me!
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
Hum, that code works perfectly for me. I would suspect that one of the values such as the password or the database name/username that you have commented out, contain a ' or a " which would create errors, you can escape them by using a back slash ( \ ) before the character.
 

websoul

New Member
Messages
39
Reaction score
0
Points
0
think u need to put something like this(with single quots)


<?php
// we connect to example.com and port 3307
$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
if (!
$link) {
die(
'Could not connect: ' . mysql_error());
}
echo
'Connected successfully';
mysql_close($link);

// we connect to localhost at port 3307
$link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
if (!
$link) {
die(
'Could not connect: ' . mysql_error());
}
echo
'Connected successfully';
mysql_close($link);
?>


Better Follow http://in.php.net/function.mysql-connect this link



hope this helps
 

vTech

New Member
Messages
34
Reaction score
0
Points
0
I am going through a php tutorial! I have finshed it but I'm confused for one part!


The part where is says yourdatabase! What do I put in there! I know it syas yourdatabase but when I do that it comes with this error when I run it!

syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/intertek/public_html/config.php on line 3


<?php

$l = mysql_connect ( "localhost" , "yourmysqlUser" , "password" ) or die("Error connecting: <br><br>".mysql_error());
mysql_select_db( "yourdatabase" ) or die("Error getting db: <br><br>".mysql_error());

?>


Some body help me!


you need to fill up "yourdatabase" with the database name u created....in x10hosting,should be yourcpanelusername_databasename....so if my cpanel name is vtech and i create a database named test, the database name will be vtech_test.
you also need a mysql username which is bout the same as database name yourcpanelusername_mysqlusername

once done fill up the bold areas of this code
PHP:
<?php
			
			$l = mysql_connect ( "localhost" , "[B]yourmysqlUser[/B]" , "password" ) or  			die("Error connecting: <br><br>".mysql_error());
			mysql_select_db[U][I][B]( "[B]yourdatabase[/B]" )[/B][/I][/U] or die("Error getting db: <br><br>".mysql_error());
			
			?>

hopefully this helps...
 

intertec

New Member
Messages
946
Reaction score
0
Points
0
I did what Vtech said but now I get new error!


Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'intertek_amir'@'localhost' (using password: YES) in /home/intertek/public_html/config.php on \line 3
Error connecting:

Access denied for user 'intertek_amir'@'localhost' (using password: YES)

Now I don't get that error! When I click login it loads but never comes up!

I did what websoul showed me!
<?php
// we connect to example.com and port 3307
$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);

// we connect to localhost at port 3307
$link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

Where it says example.com:3307 what do I input if my website is intertech.exofire.net:****

Help please!
 
Last edited:

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
kk...do this:

Code:
<?php
// we connect to example.com and port 3307
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);

// we connect to localhost at port 3307
/*I dont know why you did connect to 127.0.0.1....localhost is less letters */
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

edit in your info, and you should be set. :D
 

intertec

New Member
Messages
946
Reaction score
0
Points
0
I got new error now!

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'intertek_amir'@'localhost' (using password: YES) in /home/intertek/public_html/config.php on line 3
Could not connect: Access denied for user 'intertek_amir'@'localhost' (using password: YES)
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
That error means you can't connect to the database, make sure that your database name/user/password are correct and if they contain characters that need escaping then maybe you should change them.
 
Last edited:

vTech

New Member
Messages
34
Reaction score
0
Points
0
have you give full permission for the database username to the database?
that's why it gives an access denied error....just like verbsite said,it's the script having problem connecting to the database using the info you provided....
 

hopper

Member
Messages
225
Reaction score
0
Points
16
log into your cpanel
go to sql databases
create a database
create a user
add user to database
<?php

$l = mysql_connect ( "localhost" , "put user you created here" , "password for that user" ) or die("Error connecting: <br><br>".mysql_error());
mysql_select_db( "database you created" ) or die("Error getting db: <br><br>".mysql_error());

?>
 
Top