I am trying to insert a serialized array into mysql without column names, is it possible?
I plan to use this in a function with a dynamic number of textboxes so I will just call the function and pass the tablename and insert into the database in order.
Here is the code I currently have:
<form action = "" method = "POST">
Username: <input required type = "text" name = "register[]" / ><br />
Password: <input required type = "text" name = "register[]" / ><br />
Usertype: <input required type = "text" name = "register[]" / ><br />
Status: <input required type = "text" name = "register[]" / ><br />
<input type = "submit" name = "add" value = "add" / >
</form>
if(isset($_POST['add']))
{
$reg = serialize($_POST['register']); //takes the data from a post operation...
$register = mysql_real_escape_string($reg);
$query = mysql_query("INSERT INTO user VALUES('$register')");
}
working queries:
$query = mysql_query("INSERT INTO users (username,password,usertype,status) VALUES('$register','2','3','4')");
output:
a:4:{i:0;s:1:"1";i:1;s:1:"1";i:2;s:1:"1";i:3;s:1:"1";} 2 3 4