Basic primary level question : Above is the structure of my Mysql. When I am running : <?php // Deprecated as of PHP 5.4.0 $link = mysql_connect('localhost', "easydial_ameyaa","xxxxxxxx"); $db_list = mysql_list_dbs($link); while ($row = mysql_fetch_object($db_list)) { echo $row->Database . "\n"; } ?> Code (markup): I returns me information_schema I want to access records form candidate_list. How to do that ? I tried below code but Its returns me Blank : <CODE> <?php //connect database $con=mysql_connect("localhost","easydial_ameyaa","xxxxxx") or die(mysql_error()); // select database mysql_select_db("easydial_ameyaa",$con) or die(mysql_error());; $data="SELECT * FROM Candidate_List"; $val=mysql_query($data); while($row=mysql_fetch_object($val)) or die(mysql_error()); { echo $row->EmailID." ".$row->Salary." ".$row->JobType." ".$row->Mobile."<br/>"; } mysql_close($con); ?> </CODE>
there might be some problem with the query. Try ini_set("display_errors",1); in the beginning of the code to display all errors and then you can debug easily
Tried but No Error .. Any Issues with my code ? Why its not shwoing candidate_list as table or easydial_ameyaa as db ?
<?php //connect database $con=mysql_connect("localhost","easydial_ameyaa","xxxxxx") or die(mysql_error()); // select database mysql_select_db("easydial_ameyaa",$con) or die(mysql_error());; $data="SELECT * FROM Candidate_List"; $val=mysql_query($data); while($row=mysql_fetch_object($val)) or die(mysql_error()); { echo $row->EmailID." ".$row->Salary." ".$row->JobType." ".$row->Mobile."<br/>"; } mysql_close($con); ?> Code (markup): I tried above code..
Make sure that the user you are connecting as has access to the database you want. You say it's connecting to the information_schema, that is a default MySQL database. Also try to select the database you want in your select. Try: $data="SELECT * FROM easydial_ameyaa.Candidate_List"; Code (markup):
Don't use mysql_connect, that has been depreciated from php. Instead use PDO's. Here is a good link to get your started http://code.tutsplus.com/tutorials/php-database-access-are-you-doing-it-correctly--net-25338