Code: Select all
$user="root";
$password="1234";
$database="test";
function ExecuteNonquery($query){
//try{ //php 5.0 or higher
mysql_connect(localhost,$user,$password); //create connection
//After you have connected to the database server you must then select the database you wish to use.
//This must be a database to which your username has access. The following command:
@mysql_select_db($database) or die( "Unable to select database"); // relate to a database
mysql_query($query);
echo $query;
mysql_close();
return true;
//}catch(Exception $ex){
// echo 'Caught exception: ', $ex->getMessage(), "\n";
// return false;
//}
}and I included the db.php in Test.php
and I called the function from Test.php
Code: Select all
$query = "INSERT INTO contacts VALUES ('','John','Smith','01234 567890','00112 334455','01234 567891','johnsmith@gowansnet.com','http://www.gowansnet.com')";
ExecuteNonquery($query);When I put code toghter it works, but If I put the code in function,
it doesn't work...
What 's problem?
feyd | please use
Code: Select all
andCode: Select all
where appropriate when posting.[/color]