Page 1 of 1

if statement not working

Posted: Thu Feb 09, 2006 5:58 pm
by jasondavis
Hi im new to this but I have this chunk of code, all of it works except my newest added if statement on line 31
which is this

Code: Select all

if ($msfc[1]>=$min_usercount)
{
here is the code, does something not look correct?

Code: Select all

$min_usercount = 13000;

if (isset($_POST[Add]))
{
	// check if id is integer
	if (!is_numeric($_POST[intMSUserId]))
		$error = "Invalid MySpace User ID";

	if (is_blocked($_POST[intMSUserId]))
		$error = "Your User ID has been blocked from joining the train.";

	if ($error =="")
	{

		// check if id is already in train
		$res = mysql_query("select * from users where intMSId='$_POST[intMSUserId]'");
		$intrain = mysql_fetch_array($res);
		if ($intrain[0] == "")
		{
			//$msuser = mysql_fetch_array($res);

				// http://profile.myspace.com/index.cfm?fu ... dID=426705
				$html = 	file_get_contents("http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID=$_POST[intMSUserId]");
				preg_match("/<span class=\"nametext\">(.*)<\/span>/", $html, $msname);
				preg_match("/<td class=\"text\" width=\"193\" bgcolor=\"#ffffff\" height=\"75\" align=\"left\">\"(.*)\"<br>/", $html, 	$msdata);
				preg_match("/has <span class=\"redbtext\">(\d+)<\/span> friends/", $html, $msfc);
				preg_match("/(\d+) years old/", $html, $msyo);
				preg_match("/ctl00_Main_ctl00_.*<img src=\"(.*)\" border=\"0\" \/><\/a>/", $html, $msimg);
                preg_match('#<\s*br(?:\s*/)?>\s*((?:fe)?male)\s*<\s*br(?:\s*/)?>#is',$html,$sex);
				
				$msdata[1] = mysql_escape_string($msdata[1]);
				$msname[1] = mysql_escape_string($msname[1]);
if ($msfc[1]>=$min_usercount)
{

				if ($msname[1] != "")
				{
					mysql_query("delete from users where intMSId='$_POST[intMSUserId]'");
					$res = mysql_query("insert into users (intMSId, txtMSName, intMSAge, intMSFriends, txtMSText, txtMSImg, sex) values ('$_POST[intMSUserId]', '$msname[1]', '$msyo[1]', '$msfc[1]', '$msdata[1]', '$msimg[1]', '$sex[1]')");
			
					$res = mysql_query("select * from users where intMSId='$_POST[intMSUserId]'");
					$msuser = mysql_fetch_array($res);
                             

				} else
				{
					$error = "User doesnt exists";
				}

			
		} else
		{
			// already in the train
			$error = "You are already in this train";
		}
	} else
	{
		//$error = "Invalid MySpace User ID";
	}
}
}

Posted: Thu Feb 09, 2006 6:49 pm
by LiveFree

Code: Select all

}
if ($msfc[1]>=$min_usercount)
You were missing an } before it

Posted: Thu Feb 09, 2006 7:32 pm
by jasondavis
thats gives me an error saying I don't need the }

Posted: Thu Feb 09, 2006 7:33 pm
by feyd
what do you define as "not working" ?

Posted: Thu Feb 09, 2006 7:50 pm
by jasondavis
at the location in the script above where I put the

Code: Select all

if ($msfc[1]>=$min_usercount) 
{
and closing

Code: Select all

}
does not function at all... $msfc[1] is a friend count number and $min_usercount is the minimum friend count number allowed to proceed.

It also makes my error in my script for "Invalid MySpace User ID" show up for any entry made

Posted: Thu Feb 09, 2006 7:57 pm
by feyd
so in otherwords.. $msfc[1] is less than $min_usercount.

var_export($msfc) to see what is actually stored inside it. Might as well var_export($min_usercount) while you're at it.