Jump to content

[SOLVED] mysql_connect() help!


hungryOrb

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.