Click here to Skip to main content
15,886,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP
$conn=mysql_connect("localhost","","");
		if($conn)
		{
			$db=mysql_select_db("kart",$conn);
			$query="select * from category";
			$result=mysql_query($query,$conn);
			if($result)
			{
				$row=mysql_num_rows($result);
				echo($row);
			}
			else
			{
				echo(mysql_error($conn));
			}
		}
		else
		{
			echo("hello");
		}


it shows error -: no database selected.. why?
Posted

you did not specify a database name. only the server name
C#
conn=mysql_connect("localhost","","");


See this for an example:
http://php.net/manual/en/function.mssql-connect.php[^]
 
Share this answer
 
Comments
bhawin parkeria 11-Sep-13 13:14pm    
i want to connect to mysql not mssql,
mgoad99 11-Sep-13 13:22pm    
It is pretty obvious looking at your question that you are using mysql. Sorry about my assumption.

In case it helps, here is a link to documentation for connection to a mysql db.
http://php.net/manual/en/function.mysql-connect.php
bhawin parkeria 11-Sep-13 13:24pm    
the documentation is not helping , there is some other error,
anyway
thnx for considering my question.
check out w3schools.com --> mysql_connect
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900