PHP & MySQL - Array to string conversion error problem.
Posted
by comma
on Stack Overflow
See other posts from Stack Overflow
or by comma
Published on 2010-04-23T01:11:28Z
Indexed on
2010/04/23
1:13 UTC
Read the original article
Hit count: 290
I keep getting an the following error of Array to string conversion error
on this line listed below. How can I fix this problem?
$skill = explode('', $_POST['skill']);
Here is the PHP & MySQL code.
$skill = explode('', $_POST['skill']);
$experience = explode('', $_POST['experience']);
$years = explode('', $_POST['years']);
for ($s = 0; $s < count($skill); $s++){
for ($x = 0; $x < count($experience); $x++){
for ($g = 0; $g < count($years); $g++){
if (mysqli_num_rows($dbc) == 0) {
$mysqli = mysqli_connect("localhost", "root", "", "sitename");
$dbc = mysqli_query($mysqli,"INSERT INTO learned_skills (user_id, skill, experience, years, date_created)
VALUES ('" . $user_id . "', '" . $skill[$s] . "', '" . $experience[$x] . "', '" . $years[$g] . "', NOW())");
}
if ($dbc == TRUE) {
$dbc = mysqli_query($mysqli,"UPDATE learned_skills
SET skill = '$skill', experience = '$experience', years = '$years', date_created = NOW()
WHERE user_id = '$user_id'");
echo '<p class="changes-saved">Your changes have been saved!</p>';
}
if (!$dbc) {
print mysqli_error($mysqli);
return;
}
}
}
}
© Stack Overflow or respective owner