Jump to content


Photo

PHP5.1.2 & MySQL problem


  • Please log in to reply
1 reply to this topic

#1 kaustubhghag

kaustubhghag
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 02 March 2006 - 10:00 AM

I have Installed MySQL on windows 2000 professional operating system and then i have created ijdb as new database in which i have created joke table.

so when i tried to connect to that table and try to retrieve values it shows me following message:

Fatal error: Call to undefined function mysql_connect() in e:\Inetpub\wwwroot\connect.php on line 6


Following is the code:

html>
<head>
<title>Our List of Jokes</title>
<body>
<?php
// Connect to the database server

$dbcnx = @mysql_connect('localhost', 'root', 'mypasswd');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
// Select the jokes database
if (!@mysql_select_db('ijdb')) {
exit('<p>Unable to locate the joke ' .
'database at this time.</p>');
}
?>
<p>Here are all the jokes in our database:</p>
<blockquote>
<?php
// Request the text of all the jokes

$result = @mysql_query('SELECT joketext FROM joke');
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
// Display the text of each joke in a paragraph
while ($row = mysql_fetch_array($result)) {
echo '<p>' . $row['joketext'] . '</p>';
echo "Hello";
}
?>
</blockquote>
</body>
</html>html>
<head>
<title>Our List of Jokes</title>
<body>
<?php
// Connect to the database server

$dbcnx = @mysql_connect('localhost', 'root', 'root');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
// Select the jokes database
if (!@mysql_select_db('ijdb')) {
exit('<p>Unable to locate the joke ' .
'database at this time.</p>');
}
?>
<p>Here are all the jokes in our database:</p>
<blockquote>
<?php
// Request the text of all the jokes

$result = @mysql_query('SELECT joketext FROM joke');
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
// Display the text of each joke in a paragraph
while ($row = mysql_fetch_array($result)) {
echo '<p>' . $row['joketext'] . '</p>';
echo "Hello";
}
?>
</blockquote>
</body>
</html>


so can anyone guide what is problem

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 March 2006 - 02:42 PM

You need to enable the MySQL extrension in the php.ini file. PHP5.x no longer provides MySQL Support inbuilt and so you need to manually enable the mysql extension in the php.ini

Click [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=87276\" target=\"_blank\"]here[/a] to see how to do so.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users