sermed
sermed

Reputation: 115

data's cannot be inserted

I have database contain table named demnads table contain 11 cell first one is id auto increasement I want to add data's with this sql command in php :

<?php 
$hostname_mystore = "localhost";
$database_mystore = "mystore";
$username_mystore = "root";
$password_mystore = "";
$mystore = mysql_pconnect($hostname_mystore, $username_mystore, $password_mystore) or trigger_error(mysql_error(),E_USER_ERROR); 
mysql_query("set character_set_server='utf8'");
mysql_query("set names 'utf8'"); 
if (mysqli_connect_errno())
  {  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$sql= "INSERT into demands ( itemname , case , cname , fatora , client , cdate , ctime , prices , cmobile , numbers) values('$item[$i]','$cases[$i]','$customer[$i]','$fatora[$i]','$client[$i]','$dates[$i]','$times[$i]','$price[$i]','$mobile[$i]','$numbers[$i]' )";
?>

but data's didn't be inserted

Upvotes: 0

Views: 53

Answers (4)

Yuva Raj
Yuva Raj

Reputation: 3881

You said your table name is demnads . But in Coding you used demands? Check again.

Upvotes: 0

muratgu
muratgu

Reputation: 7311

You forgot to call mysql_query( $sql, $conn )

Upvotes: 1

Andy G
Andy G

Reputation: 19367

You have switched from the mysql library (which is deprecated) to mysqli:

mysqli_connect_errno()

You should use one or the other.

Also, embedded array values need to be enclosed in curly brackets{$item[$i]}.

This assumes, of course, that these arrays and $i are defined elsewhere.

And you haven't shown the statement that actually inserts the data.

Upvotes: 2

Sirko
Sirko

Reputation: 74046

Enclose your column names with backticks. case is a keyword within MySQL and as such can not be used as a column name without the backticks!

$sql= "INSERT into demands ( `itemname` , `case` , `cname` , `fatora` , `client` , `cdate` , `ctime` , `prices` , `cmobile` , `numbers`) values('$item[$i]','$cases[$i]','$customer[$i]','$fatora[$i]','$client[$i]','$dates[$i]','$times[$i]','$price[$i]','$mobile[$i]','$numbers[$i]' )";

Upvotes: 1

Related Questions