Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 4th, 2004, 03:23 PM
Registered User
Join Date: Feb 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't make PHP4 talk to MySQL

I have been trying for days to get my php scripts to control a mysql db. I am getting parse errors and it seems like PHP is using it's own functions and cannot recognize mysql functions like: mysql_num_rows for example.

Even when using a test script provided in a tutorial i am getting garbage on the screen:

Here's the script:
$db = mysql_connect("localhost", "root");
$result = mysql_query("SELECT * FROM employees",$db);
echo "<table border=1>\n";
echo "<tr><td>Name</td><td>Position</tr>\n";
while ($myrow = mysql_fetch_row($result)) {
  printf("<tr><td>%s %s</td><td>%s</td></tr>\n",
  $myrow[1], $myrow[2], $myrow[3]);

echo "</table>\n";

And this is what I get as output:
\n", mysql_result($result,1,"first")); printf("Last Name: %s
\n", mysql_result($result,0,"last")); printf("Address: %s
\n", mysql_result($result,0,"address")); printf("Position: %s
\n", mysql_result($result,0,"position")); ?>

If I use PHP scripts running only PHP functions, everything works great. If I include mySQL functions... it completely freaks out.

This is my current setup:
Apache Server vs. 1.3.14
MySQL vs. 3.23.32
PHP vs. 4

Any suggestions?

Old February 4th, 2004, 10:00 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts

What PHP version are you running, specifically? I'd recommend reinstalling the latest version. It sounds like something got screwed up.

For kicks, what are the contents of your employees table?

Take care,


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a pictures gallery with php & MySql Paul Weinstock Pro PHP 2 May 8th, 2009 02:50 PM
Where can I find someone I can actually talk to? sanderson Visual Basic 2008 Essentials 3 August 21st, 2008 12:17 PM
How can make pdf in php and mysql.....web applicat gupta.software ActionScript 2 May 15th, 2008 08:04 AM
all in one, php4/mySQL/phpMyAdmin/Apache server? adamhh PHP How-To 5 September 17th, 2006 05:29 AM
cannot make JSP-MySQL connection pandjie JSP Basics 1 November 12th, 2004 01:21 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.