jbulmer09 Posted July 9, 2009 Share Posted July 9, 2009 <?php $con = mysql_connect("connection","username","database"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $numbers = $_REQUEST['sendto']; $from = $_REQUEST['from']; $smsmsg = $_REQUEST['smsmsg']; $phonechunks = explode(",", $numbers); $e = count($phonechunks); for ($i=0; $i<$e; $i++) { $rawdata = "$phonechunks[$i]"; $placeholders = array('+', ' '); $vals = array('', ''); $newdata = str_replace($placeholders, $vals, $rawdata); mysql_query("INSERT INTO send (sendto, smsfrom, smsmsg) VALUES ('$newdata', '$from', '$smsmsg')"); } ?> Can any one spot the mistake? Link to comment https://forums.phpfreaks.com/topic/165339-solved-i-have-some-code-linked-to-mysql-ect-but-the-data-will-not-insert-into-mysql/ Share on other sites More sharing options...
trq Posted July 9, 2009 Share Posted July 9, 2009 Could be anywhere, why don't you try and actually debug your errors to see whats happening? eg; $sql = "INSERT INTO send (sendto, smsfrom, smsmsg) VALUES ('$newdata', '$from', '$smsmsg')"; if (!mysql_query($sql)) { echo mysql_error() . "<br>" . $sql; } ] Link to comment https://forums.phpfreaks.com/topic/165339-solved-i-have-some-code-linked-to-mysql-ect-but-the-data-will-not-insert-into-mysql/#findComment-871921 Share on other sites More sharing options...
jbulmer09 Posted July 9, 2009 Author Share Posted July 9, 2009 ok ill do this now, just to add the row is created just no info inserted inside it edit: Query was empty is the out come of that but i dont understand why, when i echo the variables that i would like to insert into the data base they show Link to comment https://forums.phpfreaks.com/topic/165339-solved-i-have-some-code-linked-to-mysql-ect-but-the-data-will-not-insert-into-mysql/#findComment-871922 Share on other sites More sharing options...
trq Posted July 9, 2009 Share Posted July 9, 2009 Yeah, well echoing the $sql var like I have shown will provide us with the details to see exactly what the database is receiving as a query. Link to comment https://forums.phpfreaks.com/topic/165339-solved-i-have-some-code-linked-to-mysql-ect-but-the-data-will-not-insert-into-mysql/#findComment-871923 Share on other sites More sharing options...
jbulmer09 Posted July 9, 2009 Author Share Posted July 9, 2009 hmm so the rariables have info in them but the query is empty. thanks for help btw the problem is in the variables, if i put in solid info like 1, it inserts it :s Link to comment https://forums.phpfreaks.com/topic/165339-solved-i-have-some-code-linked-to-mysql-ect-but-the-data-will-not-insert-into-mysql/#findComment-871924 Share on other sites More sharing options...
trq Posted July 9, 2009 Share Posted July 9, 2009 Can we see your actual query? Link to comment https://forums.phpfreaks.com/topic/165339-solved-i-have-some-code-linked-to-mysql-ect-but-the-data-will-not-insert-into-mysql/#findComment-871934 Share on other sites More sharing options...
jbulmer09 Posted July 9, 2009 Author Share Posted July 9, 2009 managed to ix it, there was a problem with the data coming in thanks for the help Link to comment https://forums.phpfreaks.com/topic/165339-solved-i-have-some-code-linked-to-mysql-ect-but-the-data-will-not-insert-into-mysql/#findComment-871942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.