My database code is:
CREATE TABLE IF NOT EXISTS symptoms_list (
id int(11) NOT NULL,
available_names varchar(255) NOT NULL
PRIMARY KEY (id)
);
My php code is:
<?php
require 'config.php';
$available_names = array (
array(‘Abdominal pain’, ‘Stomach ache’, ’Stomach trouble’, ‘Painful tommy’, ‘Tommy ache’, ‘Tommy pain’, ‘Belly ache’, ‘Belly pain’, ‘Painful tommy’),
array(‘RUQ abdominal pain’, ‘RUQ pain’, ’Right upper quadrant abdominal pain’, ‘Right upper quadrant pain’, ‘Right hypochondriac pain’ ),
array(‘Epigastric pain’, ’mid-upper abdominal pain’),
array(‘LUQ abdominal pain’, ‘LUQ pain’, ‘Left hypochondriac pain’, ‘Lt upper quadrant abdominal pain’),
array(‘Right Para umbilical pain’, ‘Rt para umbilical pain’, ‘Rt para umbilical pain’, ‘Right para umbilical abdominal pain’, ‘Pain right side of the belly button’),
array(‘Umbilical pain’, ‘Periumbilical abdominal pain’, ‘umbilical pain’, ‘Belly button pain’, ‘Umbilical ache’),
array(‘RLQ abdominal pain’, ‘Rt Lower quadrant abdominal pain’, ‘Right lower quadrant pain’, ‘Right lower quadrant abdominal pain’, ‘RLQ pain’),
array(‘suprapubic pain’, ‘Suprapubic pain’, ‘Pain below the umbilicus’, ‘Pain below the navel’, ‘Pain below the belly button’),
array(‘LLQ abdominal pain’, ‘Lt lower quadrant abdominal pain’, ‘LLQ pain’, ‘LLQ abdominal discomfort’, ‘Left lower quadrant abdominal pain’, ‘Left lower quadrant pain’),
array(‘Back pain’, ‘Pain in the back’, ‘Back ache’, ‘Back discomfort’, ‘Pain at the back’),
array(‘Fatigue’, ‘Easy fatiguability’, ’Lassitude’, ’Tiredness’, ’General weakness’, ’Exhaustion’),
array(‘Chest pain’, ‘Painful chest’, ‘Chest discomfort’, ‘Chest heaviness’),
array(‘Otalgia’, ‘Ear ache’, ’Ear pain’, ‘Ear discomfort’, ‘Painful ear’),
array(‘Otorrhea’, ‘Discharging ear’, ‘Ear discharge’)
);
// STORE ARRAY
$sql = $db->prepare("INSERT INTO symptoms_list (id, available_names) VALUES (:id, :available_names)");
// CONNECT TO DATABASE
try {
$stmt = $pdo->prepare($sql);
// Start Transaction
$stmt = $db->beginTransaction();
$array = json_decode($data, true);
// Insert each record
foreach($data as $insertRow){
// now loop through each inner array to match binded values
foreach($insertRow as $column => $value){
$stmt->bindValue(":{$column}", $value);
}
}
// Execute statement to add to transaction
$stmt->execute();
// Clear statement for next record (not necessary, but good practice)
$stmt = null;
}
// Commit all inserts
$db->commit();
?>
Each time I try to post the two dimensional array to mysql I get the error message:
"Parse error: syntax error, unexpected ';', expecting ')' in C:\xampp2\htdocs\public\symptoms7.php on line 4"