Jump to content

information not sent to the sql :(


newFreakHiba

Recommended Posts

hello

i am totally new to php

am trying to send data to my table in sql

and data isnt sent!

 

 

$ind=0;
// Create connection
$con=mysqli_connect("localhost","root","","orders");
// Check connection
if (mysqli_connect_errno($con)){echo "Failed to connect to MySQL: " . mysqli_connect_error();}
 while($ind<$_SESSION['index'])
 {
 $tempdate=date("Y-m-d");
 $buyer=$_SESSION['views'][0];
 $pid=$_SESSION['productids'][$ind];
 $pname=$_SESSION['productbought'][$ind];
 $price=$_SESSION['price'][$ind];
 $q=$_SESSION['quantityofeachproduct'][$ind];
   
  $sql="INSERT INTO order (pid, bid, price, pname, dateoforder, quantity) VALUES ('$pid','$buyer','$price','$pname','$tempdate','$q')";
 mysqli_query($con, $sql);
  var_dump($sql);
 $ind++;
Link to comment
https://forums.phpfreaks.com/topic/278090-information-not-sent-to-the-sql/
Share on other sites

Never ever run queries in loop, It’s so easy to start hammering the database with a crazy number of queries.

 

So, turn on your error_reporting and also check out that thread - http://forums.phpfreaks.com/topic/267013-looping-multiple-rows-into-database/

This is what I'm getting as an error:

 

 

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order (pid, bid, price, pname, dateoforder, quantity) VALUES ('pr000005','cl0000' at line 1 SQL: INSERT INTO order (pid, bid, price, pname, dateoforder, quantity) VALUES ('pr000005','cl000002','2499','Augi Quest ','2013-05-17','1')

 

 

I tried all the combinations of syntax(by removing or adding these '') but still don't know what to do? it's not adding

the type of inputs are all compatible I don't see any contradictions. 

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.