Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 4th, 2004, 03:23 PM
Registered User
 
Join Date: Feb 2004
Location: murrayville, ga, USA.
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:
<html>
<body>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$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";
?>
</body>
</html>

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?

Thanks,
April
Reply With Quote
  #2 (permalink)  
Old February 4th, 2004, 10:00 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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,

Nik
http://www.bigaction.org/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:51 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.