if statement not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jasondavis
Forum Commoner
Posts: 60
Joined: Sat Feb 04, 2006 5:35 pm

if statement not working

Post 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";
	}
}
}
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Post by LiveFree »

Code: Select all

}
if ($msfc[1]>=$min_usercount)
You were missing an } before it
jasondavis
Forum Commoner
Posts: 60
Joined: Sat Feb 04, 2006 5:35 pm

Post by jasondavis »

thats gives me an error saying I don't need the }
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what do you define as "not working" ?
jasondavis
Forum Commoner
Posts: 60
Joined: Sat Feb 04, 2006 5:35 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply