shlomk'e Posted December 9, 2007 Report Share Posted December 9, 2007 hey im trying to program a pm model and i want people could send their msg to a number of people in one time so i use this: <?phperror_reporting(E_ALL);if( isset( $_COOKIE['user'] ) ) { include("../config.php"); $title = $_POST['title']; $text = $_POST['text']; $name = $_COOKIE['user']; $date = date("d/m/y H:i"); $to = $_POST['to']; $a = 9999*9999; $b = 9999*9999*$a; $url = rand( $a, $b );if ($title == null || $title == "" || $text == "" || $text == null || $to == "" || $to == null) { header('Location: ../pm.php?act=send&error=gen'); exit;} else { $strings = split(" ",$to); $i = count( $strings );if ($i == 1) { $query = "SELECT username FROM members WHERE username='".$to."'"; $result = mysql_query($query);if (mysql_num_rows($result)>0) { mysql_query("INSERT INTO privatemsg (url, title, text, sendby, sendto, seen, date) VALUES ('$url', '$title', '$text', '$to', '$name', 'false', '$date')");} else { header('Location: ../pm.php?act=send&error=notexist'); exit;}} else { $c = 0;while ($c < $i) { $query = "SELECT username FROM members WHERE username='".$strings[$c]."'"; $result = mysql_query($query);if (mysql_num_rows($result)>0) { mysql_query("INSERT INTO privatemsg (url, title, text, sendby, sendto, seen, date) VALUES ('$url', '$title', '$text', '$strings[$c]', '$name', 'false', '$date')");} else { header('Location: ../pm.php?act=send&error=notexists'); exit;} $c++;}} header('Location: ../pm.php?send=true'); mysql_close($connect);} else {}?>and it isnt working... someone can take a look? Link to comment Share on other sites More sharing options...
shlomk'e Posted December 10, 2007 Author Report Share Posted December 10, 2007 it's really important JUMP Link to comment Share on other sites More sharing options...
MrAdam Posted December 10, 2007 Report Share Posted December 10, 2007 are there any errors been given?try using: mysql_query("INSERT INTO privatemsg (url, title, text, sendby, sendto, seen, date)VALUES ('$url', '$title', '$text', '$strings[$c]', '$name', 'false', '$date')") or die(mysql_error()); .. to display back the MySQL error.Adam Link to comment Share on other sites More sharing options...
Anders Moen Posted December 10, 2007 Report Share Posted December 10, 2007 Is it showing any error messages?Is it possible for us to see a demo, of some kind, or something like that? Might help...not sure tho Link to comment Share on other sites More sharing options...
justsomeguy Posted December 10, 2007 Report Share Posted December 10, 2007 How about just describing the problem. Instead of saying "it's not working", say what it is and is not doing.Also, you need to escape the variables in your SQL statements. There might be a quote or something in one of the variables that would cause the query to fail. Use this function to sanitize everything in the query:http://www.php.net/manual/en/function.mysq...cape-string.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now