Jump to content

Results of select.php? In phpMyAdMin?


eduard

Recommended Posts

What about this file? It opens! But where do I see the resulis?<html><body><?php$con = mysql_connect("localhost","root","root");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("Company", $con);$result = mysql_query("SELECT * FROM products");echo "<table border='1'><tr><th>description</th><th>price</th><th>quantity<th></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['description'] . "</td>"; echo "<td>" . $row['price'] . "</td>"; echo "<td>" . $row['quantity'] . "</td>"; echo "</tr>"; }echo "</table>";mysql_close($con);?></body></html>

Link to comment
Share on other sites

How do you know it executes? Does your browser display a table with 3 headers but no other values?
No, thus I first have to check if there is connection with my database? What is the simplest way to do that?
Link to comment
Share on other sites

Your code executes on my server and prints your first error statement. Is yours the same? If so, you are already testing the connection, and the result is false. Maybe "localhost","root","root" is not the correct data.

Link to comment
Share on other sites

Your code executes on my server and prints your first error statement. Is yours the same? If so, you are already testing the connection, and the result is false. Maybe "localhost","root","root" is not the correct data.
No, I don´t get any error messages! The file only opens. "localhost", "root", "root" are o.k.!
Link to comment
Share on other sites

I have checked the select.php and this file is ok! But do I have to intergrate the script somewhere?

Link to comment
Share on other sites

Then test the return values of mysql_select_db and mysql_query. Always test the results of mysql functions.Have you viewed the source code? You should be able to see the <html> and <body> tags. If they are not there, the file is not executing.

Link to comment
Share on other sites

Then test the return values of mysql_select_db and mysql_query. Always test the results of mysql functions.Have you viewed the source code? You should be able to see the <html> and <body> tags. If they are not there, the file is not executing.
But testing? What do you mean by that? Of course I understand testing, but how?Do I have to intergrate the script php in ahtml form?
Link to comment
Share on other sites

First answer my questions, please. 1. What do you see on the screen? Anything?2. What do you see when you view the source?You already know how to test. This is a test:

$con = mysql_connect("localhost","root","root");if (!$con){   die('Could not connect: ' . mysql_error());}

These two statements do not get tested:

mysql_select_db("Company", $con);$result = mysql_query("SELECT * FROM products");

That means that if a mysql error happens, you don't know about it.

Link to comment
Share on other sites

How do you know it executes?
This was the first question I asked you. You kept saying the file opens. Obviously you were wrong, if the url was wrong. If you had taken the time to answer my question, we could have solved the problem much sooner. When people ask you questions, they are trying to learn important information. If you don't understand the question, please say so.
Link to comment
Share on other sites

First answer my questions, please. 1. What do you see on the screen? Anything?2. What do you see when you view the source?You already know how to test. This is a test:
$con = mysql_connect("localhost","root","root");if (!$con){   die('Could not connect: ' . mysql_error());}

These two statements do not get tested:

mysql_select_db("Company", $con);$result = mysql_query("SELECT * FROM products");

That means that if a mysql error happens, you don't know about it.

Thanks! On my screen I see a table with the selected data (as required!)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...