In this after the query select * from users .............. m gettng error by writing where .....what should i use so as to print the particular user information ...................
It is not clear exactly what you are asking here. Are you asking how to print what went wrong with the MySQL query?
I also understand you want to see the results back from your query as well.
I’ve made annotations to your PHP code so I and others can try to dissect what’s going on, and you can understand to a degree what each piece of code does.
[php]
<?php
//This is your connection code. I would recommend changing the default MySQL login information for security purposes, a.k.a. creating a password for root, or creating a new account that has limited privileges. This should be relatively easy to do in MySQL Workbench. Or whatever you prefer to use.
$con=mysql_connect("localhost","root","");
//You are selecting the ttlogin database using the connection information above
mysql_select_db("ttlogin", $con);
//You've selected everything from the user table. Grave accent punctuation marks ( ` ` ) are recommended for specifying tables properly.
$result=mysql_query("SELECT * FROM `users`");
//If no result
if(!$result) {
$message = 'Query Error: ' . mysql_error();
$message .= 'Query Str: "SELECT * FROM `users`");
die ($message)
//Now you've put the data into an array of variables here. The next thing to do would be to tell PHP which variables you want out of the table. Something like:
//While There is data being fetched by each query
while ( $row = mysql_fetch_array($result) ) {
//Since I don't know what table setup you have, this would be a general layout.
//Assign each row value to a variable
$data1 = $row['data_value1'];
$data2 = $row['data_value2'];
$data3 = $row['data_value3'];
//Print the data to the screen
printf ("[ 1: $data1, 2: $data2, 3: $data3 ]
");
}
?>
[/php]
I will not consider myself an expert nor even an intermediate. But this would be the general plan that you would want to go with if I understand what you want correctly.
You can find the list of MySQL API functions here:
http://us.php.net/manual/en/book.mysql.php