The simple answer to your question.... I don't know anymore

I've tried such a variety of combination of things to correctly logon, and write to my database, but nothing seems to be working. I've tried a few things posted online but haven't got those to work either
I had the ODBC set up when I was trying to use Coldfusion, and I thought it was needed as well for the PHP code that someone sent me, but apparently I was mistaken on that, but thats good to know thanks

________________________________
Here is my flashlogin.php file, which the Charles debugger keeps echoing back...Fail
If you see any problems with this please let me know.... many thanks
_________________________________
<?php
include 'dbinfo.php';
$connect = mysql_connect(DBINFO_HOST, DBINFO_USER, DBINFO_PASS);
mysql_select_db(DBINFO_DATA, $connect);
function assignImages($uid, $arr)
{
if($arr == '0')
return;
$arr = explode(',', $arr);
foreach($arr as $val)
{
$sql = 'INSERT INTO user_images (user_id, image) VALUES ("' . $uid . '", "' . $_POST['hash'] . '-' . $val . '"); ';
$row = mysql_query($sql);
}
}
function login($username, $password)
{
$sql = 'SELECT id FROM user WHERE username = "'. $username .'" AND password =md5("' . $password . '") LIMIT 1';
$query = mysql_query($sql);
$row = mysql_fetch_assoc($query);
$userid = $row['id'];
$num = mysql_num_rows($query);
$imgUp = '0';
if(isset($_POST['imgUp']))
$imgUp = $_POST['imgUp'];
if($num > 0)
{
echo '&response=1&msg=SUCCESS&username=' . $username . '&userid=' . $userid;
assignImages($userid, $_POST['imgUp']);
} else
echo '&response=0&msg=FAIL';
}
if(isset($_POST['username']) && isset($_POST['password']))
{
login($_POST['username'], $_POST['password']);
}else{
echo '&response=0&msg=NO_INPUT';
}
?>