mysql_error()
Written by: maffelu , 2009-03-15 14:18:45
<?php
//Create a connection
$link = mysql_connect("localhost", "username", "password");
//Select database
mysql_select_db("examples", $link);
//Create a query
$sql = "SELECT * FOM Person"; //Faulty query....
//Execute the query
$result = mysql_query($sql, $link);
if($result)
{
//If correct, do something here...
echo "The query worked!!!";
}
else
{
//If the query was unsucceful, we will output the error
echo "<b>Error ".mysql_errno($link).":</b> ".mysql_error($link);
}
//Close the connection
mysql_close($link);
?>
There are no comments on this article.
If you have any question or just want to leave a message, just fill out the form below!
Your e-mail will not be visible in your post, it is for validation reasons only
Maffelu
Creator and admin of MorkaLork.com.
Started programming in HTML back when frames and tables was the way to design a page, moved on to Pascal/Delphi, PHP, javascript/jQuery, VB.NET/C#, Java and C++.
Currently studies .NET (in general) focusing on ASP.NET.