timmah1 Posted March 30, 2009 Share Posted March 30, 2009 Why when I use following code, does it only insert the first character of every $_POST instead of the full $_POST? <?php $count = count($_POST['pack']); for ($i = 0; $i < $count; $i++) { $price1 = "comp"; $processor = "Admin Insert"; $price = $price1[$i]; $processor = $processor[$i]; $email = $_POST['email'][$i]; $pass = $_POST['pass'][$i]; $exp = $_POST['yr']."-".$_POST['month']."-".$_POST['day'][$i]; $val = $_POST['pack'][$i]; $sql = "INSERT INTO members1(package, price, email, password, processor, purchase, exp) VALUES( '$val', '$price', '$email', '$password', '$processor', NOW(), '$exp');"; mysql_query($sql) or die("Sorry, there was a problem creating your account ".mysql_error()); } ?> Thanks in advance Link to comment https://forums.phpfreaks.com/topic/151683-solved-insert-problem/ Share on other sites More sharing options...
Maq Posted March 30, 2009 Share Posted March 30, 2009 Because when you do something like: $arr['test']="hello"; echo $arr['test'][0]; ?> OUTPUT: h It's only echoing out the first letter, it's kind of like the string is an array, with each element being a letter. Link to comment https://forums.phpfreaks.com/topic/151683-solved-insert-problem/#findComment-796536 Share on other sites More sharing options...
timmah1 Posted March 30, 2009 Author Share Posted March 30, 2009 oh, I see. Thanks Maq Link to comment https://forums.phpfreaks.com/topic/151683-solved-insert-problem/#findComment-796538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.