Jump to content

Recommended Posts

Hello! I just installed PHP and MySQL to work with localhost. However, when I try the mysql_connect function, it returns:

 

Fatal error: Call to undefined function mysql_connect() in ..\index.php on line 13

 

..\ is usually the whole line obviously. I asked someone I knew, if this was because MySQL was not installed properly, and he thinks it is. Does anyone know how to remedy this?

TIA!

 

Link to comment
https://forums.phpfreaks.com/topic/72934-solved-mysql_connect-help/
Share on other sites

<html>
<body>

<?php 

function connect(){
$dbserver = '127.0.0.1';
$dbuser = 'WOOPS';
$dbpassword = 'PASSWORD';
$dbschema = 'db';

try{
	$db = mysql_connect($dbserver, $dbuser, $dbpassword);
}catch(Exception $e){
	echo $e->getMessage();
}
if ($db==false){
	echo "Database connection failure\n<br>";
	echo mysql_error();
	}

mysql_select_db($dbschema);
echo mysql_error();
return $itdblink;
}

function disconnect(){
mysql_close();
}

connect();

$query('SELECT * FROM test');
$result = mysql_query($query) or die('Query messed up: ' . mysql_error());

echo $result;

?>

</body>
</html>

 

KK here tis:

Try this.

 

<?php
$db_server ="edit";
$db_user = "edit";
$db_pass = "edit";
$db_name = "edit";


$con = mysql_connect("$db_server","$db_user","$db_pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}


mysql_select_db("$db_name", $con);
$result = mysql_query("SELECT * FROM your tabel");
while($row = mysql_fetch_array($result))
{
echo $row['any column in your table'];
echo "<br />";
}
mysql_close($con);
?>

 

I am new to php so i can't guarentee this will work

Thankyou guys, I'll check this out when I get home. ;] much appreciated!  :-*

If you searched this forum with that error message you would of gotten the answer adam291086 has just came up with.  There is even a sticky titled as the error message you are getting within the PHP Help board!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.