Hello
Can someone please check my code snippet below (only part of code included!). PHP form that checks $name doesn't already exist and then inserts them into mySQL database. All works except for the $counted variable. $list is a string that looks something like this: 123,2536,2346,332,546. So in this instance $counted should have a value of 5 because there are 5 values in the string. But it gets inserted as 0. Cannot see what I am doing wrong.
Many thanks!
if (isset($_POST['submit'])) {
$name=$HTTP_POST_VARS['name'];
$passw=$HTTP_POST_VARS['passw'];
$list=$HTTP_POST_VARS['list'];
$plot=$HTTP_POST_VARS['plot'];
if ($name && $passw && $list && $plot) {
$list_array = explode (',',$_POST['list']);
$string_list = implode (',',$list_array);
$sql = "SELECT id FROM table WHERE id IN($string_list)";
$result=mysql_query($sql);
$counted = mysql_num_rows($result);
$qstr = mysql_query("select id FROM table WHERE name='$name'")
or die ("Could not log you in.");
if (mysql_num_rows($qstr) == 0) {
$query ="INSERT INTO table (name,passw,list,plot,counted)";
$query.=" VALUES ('$name','$passw','$list','$plot','$counted')";
$result=mysql_query($query);
if ($result) {
header("Location: http://...whatever...");