Проблемы с отправкой в ​​базу данных cURL

ОБНОВЛЕНО ОТ 11/16/15 11:55 вечера PST

Ниже вы найдете код.

Я пытаюсь получить это для получения данных JSON и отправьте значения в мою базу данных.

Структура JSON и в каком порядке выводится …

[{ "record_locator": "value", "status": "value", "area": "value", "region": "value", "name": "value", "position":"value", "phone_": "value", "project_manager": "value", "ipad_email": "value", "email": "value", "team_leader": "value", "regional": "value", "title": "value", "start_date": "value", "employee_id_number": "value", }] 

Для легких глаз …

$ VAR = MY TABLE KEY = JSON KEY

 $area =area =area $email =email =email $ipad_email =ipad_email =ipad_email $empid =empid =employee_id_number $fullname =fullname =name $manager =manager =If Clause $mobilenumber =mobilenumber =phone_ $record_locator =record =record_locator $status =status =status $region =region =region $position =position =position $project_manager =project_manager =project_manager $team_leader =team_leader =team_leader $regional =regional =regional $title =title =title $startdate =startdate =startdate 

Я сделал простой тест эха значения, и они хватают его, просто по какой-то причине его не публикует в базе данных. Я не могу понять это печально.

Любая помощь будет принята с благодарностью.

  <html> <head> <style> td { text-align:center; border: 1px solid black; } </style> </head> <body> <div style="margin-top:5%; width:300px; margin:auto; border: 1px solid black; padding:3px;"><center><p id="container">Loading...</p></div> <?php $error_msg = ""; $url="someurl.com"; $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); $json = curl_exec($ch); curl_close($ch); $rdata = json_decode($json, TRUE); $c=0; $repverified = 0; foreach ($rdata as $data) { // Assigned key JSON KEY $user_rl = $rdata[$c]['record_locator']; $status = $rdata[$c]['status']; $area = $rdata[$c]['area']; $region = $rdata[$c]['region']; $fullname = $rdata[$c]['name']; $position = $rdata[$c]['position']; $mobilenumber = $rdata[$c]['phone_']; $project_manager = $rdata[$c]['project_manager']; $ipad_email = $rdata[$c]['ipad_email']; $email = $rdata[$c]['email']; $team_leader = $rdata[$c]['team_leader']; $regional = $rdata[$c]['regional']; $title = $rdata[$c]['title']; $startdate = $rdata[$c]['start_date']; $empid = $rdata[$c]['employee_id_number']; if( $fullname == $rdata[$c]['project_manager'] || $fullname == $rdata[$c]['team_leader'] || $fullname == $rdata[$c]['regional'] || $fullname == $rdata[$c]['director']) { $manager = 'YES'; } else { $manager = 'NO'; } // Insert the new user into the database $sql = " INSERT INTO members ( record, status, area, region, fullname, manager, position, mobilenumber, project_manager, ipad_email, email, team_leader, regional, title, startdate, empid ) VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $insert_stmt = $mysqli->prepare($sql); // Insert the new user into the database if ($insert_stmt) { $insert_stmt->bind_param('ssssssssssssssss',$user_rl,$status,$area, $region,$fullname,$manager,$position,$mobilenumber, $project_manager,$ipad_email,$email,$team_leader, $regional,$title,$startdate,$empid); // Execute the prepared query. if (! $insert_stmt->execute()) { header('Location: ../error.php?err=Registration failure: INSERT'); } } } echo '<div>Check to ensure we are grabbing the values</div>'; echo '<td>'. $user_rl .'</td><br>'; echo '<td>'. $status .'</td><br>'; echo '<td>'. $area .'</td><br>'; echo '<td>'. $region .'</td><br>'; echo '<td>'. $fullname .'</td><br>'; echo '<td>'. $manager .'</td><br>'; echo '<td>'. $position .'</td><br>'; echo '<td>'. $mobilenumber .'</td><br>'; echo '<td>'. $project_manager .'</td><br>'; echo '<td>'. $ipad_email .'</td><br>'; echo '<td>'. $email .'</td><br>'; echo '<td>'. $team_leader .'</td><br>'; echo '<td>'. $regional .'</td><br>'; echo '<td>'. $title .'</td><br>'; echo '<td>'. $startdate .'</td><br>'; echo '<td>'. $empid .'</td><br>'; $c++; echo "<script>document.getElementById('container').innerHTML = 'Registration Completed!<br><b> Active Users will now be visible</b>';</script>"; ?> номер  <html> <head> <style> td { text-align:center; border: 1px solid black; } </style> </head> <body> <div style="margin-top:5%; width:300px; margin:auto; border: 1px solid black; padding:3px;"><center><p id="container">Loading...</p></div> <?php $error_msg = ""; $url="someurl.com"; $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); $json = curl_exec($ch); curl_close($ch); $rdata = json_decode($json, TRUE); $c=0; $repverified = 0; foreach ($rdata as $data) { // Assigned key JSON KEY $user_rl = $rdata[$c]['record_locator']; $status = $rdata[$c]['status']; $area = $rdata[$c]['area']; $region = $rdata[$c]['region']; $fullname = $rdata[$c]['name']; $position = $rdata[$c]['position']; $mobilenumber = $rdata[$c]['phone_']; $project_manager = $rdata[$c]['project_manager']; $ipad_email = $rdata[$c]['ipad_email']; $email = $rdata[$c]['email']; $team_leader = $rdata[$c]['team_leader']; $regional = $rdata[$c]['regional']; $title = $rdata[$c]['title']; $startdate = $rdata[$c]['start_date']; $empid = $rdata[$c]['employee_id_number']; if( $fullname == $rdata[$c]['project_manager'] || $fullname == $rdata[$c]['team_leader'] || $fullname == $rdata[$c]['regional'] || $fullname == $rdata[$c]['director']) { $manager = 'YES'; } else { $manager = 'NO'; } // Insert the new user into the database $sql = " INSERT INTO members ( record, status, area, region, fullname, manager, position, mobilenumber, project_manager, ipad_email, email, team_leader, regional, title, startdate, empid ) VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $insert_stmt = $mysqli->prepare($sql); // Insert the new user into the database if ($insert_stmt) { $insert_stmt->bind_param('ssssssssssssssss',$user_rl,$status,$area, $region,$fullname,$manager,$position,$mobilenumber, $project_manager,$ipad_email,$email,$team_leader, $regional,$title,$startdate,$empid); // Execute the prepared query. if (! $insert_stmt->execute()) { header('Location: ../error.php?err=Registration failure: INSERT'); } } } echo '<div>Check to ensure we are grabbing the values</div>'; echo '<td>'. $user_rl .'</td><br>'; echo '<td>'. $status .'</td><br>'; echo '<td>'. $area .'</td><br>'; echo '<td>'. $region .'</td><br>'; echo '<td>'. $fullname .'</td><br>'; echo '<td>'. $manager .'</td><br>'; echo '<td>'. $position .'</td><br>'; echo '<td>'. $mobilenumber .'</td><br>'; echo '<td>'. $project_manager .'</td><br>'; echo '<td>'. $ipad_email .'</td><br>'; echo '<td>'. $email .'</td><br>'; echo '<td>'. $team_leader .'</td><br>'; echo '<td>'. $regional .'</td><br>'; echo '<td>'. $title .'</td><br>'; echo '<td>'. $startdate .'</td><br>'; echo '<td>'. $empid .'</td><br>'; $c++; echo "<script>document.getElementById('container').innerHTML = 'Registration Completed!<br><b> Active Users will now be visible</b>';</script>"; ?> 

Добавлено эхо, чтобы дважды проверить, что мы захватываем значения. Успех! Мы!

 echo '<div>Check to ensure we are grabbing the values</div>'; echo '<td>'. $user_rl .'</td><br>'; echo '<td>'. $status .'</td><br>'; echo '<td>'. $area .'</td><br>'; echo '<td>'. $region .'</td><br>'; echo '<td>'. $fullname .'</td><br>'; echo '<td>'. $manager .'</td><br>'; echo '<td>'. $position .'</td><br>'; echo '<td>'. $mobilenumber .'</td><br>'; echo '<td>'. $project_manager .'</td><br>'; echo '<td>'. $ipad_email .'</td><br>'; echo '<td>'. $email .'</td><br>'; echo '<td>'. $team_leader .'</td><br>'; echo '<td>'. $regional .'</td><br>'; echo '<td>'. $title .'</td><br>'; echo '<td>'. $startdate .'</td><br>'; echo '<td>'. $empid .'</td><br>'; 

СХЕМА БД

 CREATE TABLE IF NOT EXISTS `memberss` ( `id` int(11) NOT NULL AUTO_INCREMENT, `empid` varchar(5) COLLATE utf8_unicode_ci NOT NULL, `record` varchar(20) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `status` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `area` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `region` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `fullname` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `position` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `mobilenumber` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `project_manager` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `ipad_email` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `email` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `regional` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `title` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `startdate` varchar(100) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;