Please i'm newbie and i want to connect to a mysql database: here is my code:
<?php
/* conexão à base de dados vendas*/
$mysql_id = mysql_connect('localhost', 'curso', '123');
mysql_select_db($mysql_id, 'vendas');
if (!$mysql_id){
die ('ops erro');
}
if (!$mysql_select_db){
die ('erro no slee '.mysql_error());
}
?>
The result in my webbrowser is:
Warning: mysql_select_db() expects parameter 1 to be string, resource given in C:\xampp\xampp\htdocs\vendasphp\vendas.php on line 6
erro no slee
Why? What i'm doing wrong?
Thank you
mario
Connect Mysql error, where?
Moderator: General Moderators
-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
Re: Connect Mysql error, where?
Ok Guys I'm really a newbie. Here is the right code:
<?php
/* conexão à base de dados vendas*/
$mysql_id = mysql_connect('localhost', 'curso', '123');
mysql_select_db($mysql_id,'vendas');
if(!mysql_select_db('vendas',$mysql_id)){
die ('Erro'.mysql_error());
}
?>
But i get the warning
Warning: mysql_select_db() expects parameter 1 to be string, resource given in C:\xampp\xampp\htdocs\vendasphp\vendas.php on line 6
Why?
<?php
/* conexão à base de dados vendas*/
$mysql_id = mysql_connect('localhost', 'curso', '123');
mysql_select_db($mysql_id,'vendas');
if(!mysql_select_db('vendas',$mysql_id)){
die ('Erro'.mysql_error());
}
?>
But i get the warning
Warning: mysql_select_db() expects parameter 1 to be string, resource given in C:\xampp\xampp\htdocs\vendasphp\vendas.php on line 6
Why?
Re: Connect Mysql error, where?
Code: Select all
mysql_select_db('vendas', $mysql_id);-
mariolopes
- Forum Contributor
- Posts: 102
- Joined: Sun May 22, 2005 7:08 am
Re: Connect Mysql error, where?
Solved
Thank you for your help
Thank you for your help