Connect to DB - error
Posted: Thu Mar 25, 2010 5:06 am
Dear all I am a beginer of PHP, MySQL,
I installed the WAMP 2.0 server and I try to following code:
Anyway I add a user1 and pass wd "testing" from previlages. and also I change the passwd of root (in previlages) as "test" also i change the pass wd in "C:\Program_files\wamp\apps\phpmyadmin3.2.0.1\config.inc.php" fie set passwd as foloows;
then after I run this above code in the local host there have the error in line 9, which is
"$Connect=mysql_connect('localhost',$User,$passwd, , ) or die('Could not connect : ' );"
ERROR IS DISPLAY AS
"Parse error: parse error in C:\Program_files\wamp\www\connectDB.php on line 9"
please give me a help to find out where is the wrong in my coding or WAMP configuration process.
Thanks
I installed the WAMP 2.0 server and I try to following code:
Code: Select all
<?php echo $_SERVER['SCRIPCT_NAME']. "<br>"; ?>
<?php
echo "<b> Intro: let's do a little genric database owork !</b> <br><br>";
$user="user1";
$passwd = "test";
$Loc="locaalhost";
//connecting to and selecting a database
$Connect=mysql_connect('localhost',$User,$passwd, , ) or die('Could not connect : ' );
echo '<b> Step 1:</B> Connected successfully! <br> ';s
$db = 'samples';
mysql_select_db ($db) or die ('Could not select database ('.$db.') because of : ');
echo '<b> Step 2: </b> Connected to ('.$db.') successeful! <br>';
mysql_close ($connect) ;
?>
Code: Select all
<?php
/* Servers configuration */
$i = 0;
/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = [i]'test';[/i]
$cfg['Servers'][$i]['AllowNoPassword'] = true;
/* End of servers configuration */
$cfg['DefaultLang'] = 'en-utf-8';
$cfg['ServerDefault'] = 1;
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
?>
"$Connect=mysql_connect('localhost',$User,$passwd, , ) or die('Could not connect : ' );"
ERROR IS DISPLAY AS
"Parse error: parse error in C:\Program_files\wamp\www\connectDB.php on line 9"
please give me a help to find out where is the wrong in my coding or WAMP configuration process.
Thanks