Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help with an undefined function
Old 08-14-2005, 04:10 PM Help with an undefined function
Skilled Talker

Posts: 64
Trades: 0
I've just started to run PHP and MySQl with an apache server on my home PC. I've created a PHP program to communicate with the MySQL server to access some information on the test table. However, I constantly receive this line when accessing the page:

Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\query_test.php on line 7

This is the code I have used (Note, the XXXXXXXXX is the password and this line:

$connection=mysql_connect("localhost","root","XXXX XXX")

is the 7th line on my editor, and so therefore is the problematic line)

PHP Code:
<html>
<head>
<title>Query Test</title>
</head>
<body>
<?php
$connection
=mysql_connect("localhost","root","XXXXXXX")
or die (
"Server is down right now, due to a problem with the PHP documents communicating with the server. We should be back up soon!");
$database "Members";
$db mysql_select_db($database,$connection)
or die (
"Server is down right now, due to a problem with the PHP documents communicating with the server. We should be back up soon!");
$query "SELECT * FROM test";
$result mysql_query($query)
or die (
"Couldn't execute query");
mysql_close($connection);
?>
</body> 
</html>

Can anyone explain to me what I'm doing wrong? I really want to be able to understand but I can't see what I'm doing wrong? Am I missing out a part of code that I need to put in?
Tomos is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-14-2005, 04:39 PM
pushedtomb's Avatar
Super Talker

Posts: 100
Name: Nathen
Location: Casnewydd, De Cymru, UK
Trades: 0
try
PHP Code:
 $connection = @mysql_connect("localhost""root""XXX") or die ("Could not connect due to".mysql_error());
$database"Members";
$db = @mysql_select_db($database$connection) or die ("Could not open database due to".mysql_error());
//rest of code.... 
__________________

Please login or register to view this content. Registration is FREE


Quote:
- "I've often wondered how MS can say that other software "isn't compatible" with MS when MS stuff isn't even compatible with other MS stuff" - quote from Daily Thing.com
pushedtomb is offline
Reply With Quote
View Public Profile
 
Old 08-14-2005, 04:42 PM
Skilled Talker

Posts: 64
Trades: 0
I no longer get the error message. Now I need to find out how to display the tables.

Can you explain why that worked compared to mine for future knowledge?

Thanks!
Tomos is offline
Reply With Quote
View Public Profile
 
Old 08-14-2005, 04:57 PM
pushedtomb's Avatar
Super Talker

Posts: 100
Name: Nathen
Location: Casnewydd, De Cymru, UK
Trades: 0
i think that the @ suppresses the errors, im not sure though :S... to pull things out of the database use the SELECT statement.

PHP Code:
 //connection info here
 
$query "SELECT * FROM table";
 
$result =  mysql_query("query") or die ("Could not select info from database due to".mysql_error());
 while (
$row mysql_fetch_array($result) ) {
 
 
$id $row['id'];
 
$title $row['title'];
 
//other fields you want must be set out the same
 
print ('<a href=\'?id='.$id.'>'.$title.'</a><br />');
 
//rest of coding and close database connection 
__________________

Please login or register to view this content. Registration is FREE


Quote:
- "I've often wondered how MS can say that other software "isn't compatible" with MS when MS stuff isn't even compatible with other MS stuff" - quote from Daily Thing.com

Last edited by pushedtomb; 08-14-2005 at 05:06 PM..
pushedtomb is offline
Reply With Quote
View Public Profile
 
Old 08-14-2005, 05:05 PM
Skilled Talker

Posts: 64
Trades: 0
Thanx
Tomos is offline
Reply With Quote
View Public Profile
 
Old 08-14-2005, 05:35 PM
asm
Extreme Talker

Posts: 217
Location: UK.Lancashire(true)
Trades: 0
i think you should take the @ out of the script as you will never find the problem with it left in because this will suppress any error and therefore you will not no what is wrong due to the lack of output from the php parser.
asm is offline
Reply With Quote
View Public Profile Visit asm's homepage!
 
Old 08-14-2005, 06:53 PM
Skorch1's Avatar
Super Talker

Posts: 115
Location: California
Trades: 0
Good point ASM! Imagine looking through all your lines of looking for a simple syntax error, not even knowing where to look for who knows what error.
__________________
Check out my
Please login or register to view this content. Registration is FREE
website!
Skorch1 is offline
Reply With Quote
View Public Profile Visit Skorch1's homepage!
 
Old 08-15-2005, 10:13 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
If it is php5 you are using, this may be of interest:
http://www.php.net/manual/en/faq.dat...ses.mysql.php5
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 08-15-2005, 12:16 PM Thanx!
Skilled Talker

Posts: 64
Trades: 0
Thanx guys! I'll try that now!
Tomos is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with an undefined function
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.09925 seconds with 12 queries