php sql insert into not working -


i new php coding reason code isn't inserting table. i've been working on problem few hours , can't figure out @ all.

i use php admin , used generate php script (not current version of code), still didn't work.

<?  //data  $id = $_get['id']; $type = $_get['type']; $name = $_get['name']; $addr = $_get['addr']; $phone = $_get['phone']; $startdate = $_get['startdate']; $enddate = $_get['enddate']; $srn = $_get['srn'];  //sql info $user = $_get['user']; $pass = $_get['pass'];  echo "   hostname: $id dev_type: $type user_name: $name user_addr: $addr user_phone: $phone date_start: $startdate date_end: $enddate square recipt number: $srn  ";    // sql insert  $con=mysqli_connect("mysql1098.servage.net",$user,$pass,"rc_db");  mysqli_query($con,"insert rc_db.current_rentals (hostname,dev_type,user_name,user_addr,user_phone,date_start,date_end,stolen,square_recipt_number) values ($id,$type,$name,$addr,$phone,$startdate,$enddate,'0',$srn)");  mysqli_close($con);  ?> 

any ideas?

you need have apostrophes around text items. has confused me in past, too. not adding parameters function, quoting text passed mysql. so, $name should '$name'. try similar following:

mysqli_query($con, "insert rc_db.current_rentals  (hostname,dev_type,user_name,user_addr,user_phone,date_start,date_end,stolen,square_recipt_number) values ('$id','$type','$name','$addr','$phone','$startdate','$enddate','0','$srn')"); 

edit: way troubleshoot php sql statements echo text , try run code in phpmyadmin. phpmyadmin gives better error messages php does.

var $text = "insert ... (...) values ('$id', '$type'...)"; echo $text; 

after works, can add text variable mysqli_query call , see if works.

var $text = "insert ... (...) values ('$id', '$type'...)"; mysqli_query($con, $text); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -