Help me PHP CODE CONNECT TO DATABASE

Hello anyone can help me what i did wrong with this code… i need connect to database here code is

<?php

mysql_connect("localhost","root") or die(mysql_error);
mysql_select_db("tutorial02") or die (mysql_error());

echo "wait";

?&gt;

Is i did right or wrong i was try make a page of reisgter, log in, log out user for my website please HELP!!!

Thanks James

please get your mysql info in your cpanel. localhost is not support in 000webhost.

U mean want me copy the info mysql paste in here to tell u what the wrong is. so how could i change localhost? coz i has follow the info from website seem not work for me… please help me.

You should see something like this in your cpanel under mysql.

MySQL databases are required by many web applications including bulletin boards, content management systems, and others. To use MySQL, you need to create database and user, which will be automatically assigned to this database. Click for phpMyAdmin when database is created.

Important: MySQL Host for any database in this account is mysql12.000webhost.com , do not use localhost!

You mysql might not be 12.

See a sample here:

Yes its say “mysql13.000webhost.com

SO i dont understood on this website say localhost. something i did aswell.

please can u make a code then reply me on here if u can.?

thanks

click on the link I gave you and copy the code and change the mysql info to match your cpanel mysql info.

The link gave you the whole code, you just need to change to your mysql info.

Please read all the info before ask. They give you lot of information there.

U mean its right one code is?

<?php
$con = mysql_connect("<?php
$con = mysql_connect(“localhost”,“mysql_user”,“mysql_pwd”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

// some code

mysql_close($con);
?> ",“mysql_user”,“mysql_pwd”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

// some code

mysql_close($con);
?>

or wrong?

i just learn how connect to database cz i never been did it before… i am beinger…

replace this with your own mysql info that you got from cpanel
$con = mysql_connect(“localhost”,“mysql_user”,“mysql_pwd” );

U mean this one.

<?php

mysql_connect(localhost","root") or die(mysql_error);
mysql_select_db("tutorial02") or die (mysql_error());

echo "wait";

?&gt;

But its still got error…

look the site. is http://deaf-awareness.netai.net/

thanks

Sorry my bad. wrong copy&paste
i mean this

<?php
$con = mysql_connect(“mysql13.000webhost.com”,“a7558329_1”,“lollol09”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

// some code

mysql_close($con);
?>

still got error tho.

Note you have a whitespace after your username: "a7558329_1 " still within quotes

I mean this!!

<?php
$con = mysql_connect(“mysql13.000webhost.com”,“a7558329_1”,“lollol09”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

// some code

mysql_close($con);
?>

still got error!

There nothing… they is together.:S

(“mysql13.000webhost.com”,"[U]a7558329_1 [/U]",“lollol09”);

look at the underlined string… whitespace after 1

Nope i been check clear on my dreamweaver its together… anyway i was try make a reisgter, then i got error so i put blank now… how make a script for reisgter make work with database. or u could check on mine than?

i dont mind

To be honest, your script looks good. Although your user name looks off… atleast the _1 part…

If you are trying to use Dreamweaver to connect remotely to your database, you cannot.

Are you running the script locally or uploading it to your FTP first, and then visiting your domain?

I was upload the file to pubic_html so i need a script work within reisgter and log in, log out. i been try everything for an months no luck for me… i think about to give up make a log in,log out user and reisgter…

did you create your mysql database on 000webhost?

Yes ofc i did… but dont know how make a code of log in,log out. and reisgter… any cule can help me about it?