I am trying to do a very simple thing of listing records in MySQL database. I have db called 'property' with a table property_list I can access the database using MySQL Query browser with no problems and also execute there the same query which gives me desired results. I am using in this php the same username and password to connect to db so I imagine I am connecting to db ok especially as I do not get any errors. However, when I execute the code below in the browser, all that I get as a result in a browser window is the following: "; } mysql_close($con); ?> which represent few last line(s) of php What am I doing wrong? Many thanks! ================================================ <?php $con = mysql_connect("localhost","root","cvfs"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("property", $con); $result = mysql_query("SELECT * FROM property_list"); while($row = mysql_fetch_array($result)) { echo $row['property_ref'] . " " . $row['property_short_title']; echo "<br />"; } mysql_close($con); ?> ================================================
If you view the source code of the page, you'll probably see the whole code there. It looks like you don't have PHP set up correctly on your server.
Thanks on your reply. I have only installed MySQL and thought this is enough, obviously not! I looked on the web on installing php environment, do I have to install Apache server too or installing php will be enough? Thanks.
just find a bundled apache + php + mysql server. it's easier to develop at your home. Try to install xampp or wamp.
Yeah, install XAMPP [apachefriends.org] It's pretty straightforward. Once it's installed(I installed to C:\XAMPP) put all of your files in the HTDOCS folder, which for me is C:\XAMPP\htdocs