Problem connecting to Database in mysql using PHP
Posted: Fri Aug 29, 2003 3:47 pm
hi ,
I am new to PHP. I am trying to connect to a database and then to select something from it.
$connection=mysql_connect("xxxxxxx","xxxxx","xxxxx") or die(mysql_error());
This works fine but then I have a database name student and user name dbadmin.
in mysql I have granted all privileges to dbadmin on student.but when I try to use student as my database with dbadmin as user it gives me the below error :
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
this is my code below :
<?
$connection=mysql_connect("xxxx","dbadmin","xxxxx") or die(mysql_error());
if ($connection)
{
$msg = "Success !!";
}
$db_name = "student";
$db = mysql_select_db($db_name,$connection);
$query = "select * from system_user";
$result = mysql_query($query, $db);
if(!$result)
{
$msg = "ERROR : Not getting the database !!";
}
?>
<html>
<head><title> Mysql Connection </title></head>
<body>
<? echo "$msg"; ?>
</body>
</html>
PLEASE HELP !!
Thanks in advance
I am new to PHP. I am trying to connect to a database and then to select something from it.
$connection=mysql_connect("xxxxxxx","xxxxx","xxxxx") or die(mysql_error());
This works fine but then I have a database name student and user name dbadmin.
in mysql I have granted all privileges to dbadmin on student.but when I try to use student as my database with dbadmin as user it gives me the below error :
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
this is my code below :
<?
$connection=mysql_connect("xxxx","dbadmin","xxxxx") or die(mysql_error());
if ($connection)
{
$msg = "Success !!";
}
$db_name = "student";
$db = mysql_select_db($db_name,$connection);
$query = "select * from system_user";
$result = mysql_query($query, $db);
if(!$result)
{
$msg = "ERROR : Not getting the database !!";
}
?>
<html>
<head><title> Mysql Connection </title></head>
<body>
<? echo "$msg"; ?>
</body>
</html>
PLEASE HELP !!
Thanks in advance