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 Quote 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. Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/151683-solved-insert-problem/#findComment-796538 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.