|
Hi
I am very new to this, so any help would be greatly appreciated.
I have an array which splits numbers by semi-colon. It then posts it to my database, however it just put the number value as the word "array" in the table.
Everything splits fine into seperate rows my only problem is that the "numbers" that should appear in the number column in the table appear as the word "array".
Below is the code that I am using
<?php
$cellno = $_POST['number'];
$text = $_POST['message'];
$userid = $_POST['userid'];
$str = $cellno;
$strList = ltrim($str,";");
$strList = rtrim($str,";");
//echo $strList."<br>";
$strListExp = explode(";",$strList);
$strListSplit = array_chunk($strListExp,1);
$NumberOfstr = sizeof($strListSplit);
//print_r($strListSplit);
include 'opendb.php';
// Performing SQL query
foreach($strListSplit as $number)
{
$sql = "INSERT INTO smsouttest (number,text,userid) VALUES ('$number','$text','$userid')";
echo $sql;
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
}
// Closing connection
mysql_close($conn);
?>
Thanks.
Carl
|