Can't figure out why this is failing...

I’m not sure why this bit is failing
[php]$san_label = mysql_real_escape_string(strtolower($_POST[‘label’]));
$flabel = mysql_query(“SELECT label FROM venzo_clients WHERE label = ‘$san_label’”) or die(mysql_error());

$badLabels = array('unknown','unknwn','unkn','ukn','indie','unsigned','independent','indie label','n/a','unsigned artist','artist','not available','none','none available','independent label','label','non','-','_','not signed', 'no signed', 'signed', 'nosigned', 'ns');

if(!empty($_POST[‘label’])) {

	if(mysql_num_rows($flabel) > 0) {
		$err['badlabel'] = "Label is in use";
	}
	
	if(in_array($san_label, $badLabels)) {
		$err['badlabel'] = "Invalid label name";
	}
	// more code below here

}[/php]
Basically, I have 2 searches going on, the top one uses a query to search existing labels and one that uses an array of invalid labels. Its the second one that’s failing.

At the bottom, I use an if statement to test for $err, and I’m thinking that maybe why its failing - if(!$err) {…}

I can’t get it to fail, but I know it is because when someone registers, it sends out an email to me and the client, and the label is one from the bad label array, in this case it was independent. I’m loosing the last of my marbles trying to figure this out, hopefully someone can shed some light.

Add some logging so you can see who requested it, what their post data was (post label)

Also you really shouldn’t be using mysql_*…

Yea I know, I just don’t want to take the time to switch over. i’ll add the extra logging, see where it goes.

I don’t know what’s going on, I can’t get it to break. I added some additional error messages and changed them to red, so maybe the clients will see them this time around. If that doesn’t work, i’ll have to rethink how the validation is done.

[php]if(!empty($_POST[‘label’])) {

$badLabels = array('unknown','unknwn','unkn','ukn','indie','unsigned','independent','indie label','n/a','unsigned artist','artist','not available','none','none available','independent label','label','non','-','_','not signed', 'no signed', 'signed', 'nosigned', 'ns');

$san_label = mysql_real_escape_string(strtolower($_POST[‘label’]));

if(in_array($san_label, $badLabels)) {

	$err['badlabel'] = "Invalid label name";

} else {  // You know you have a bad label name, why check the table? (Unless I don't know something about your code)

	$flabel = mysql_query("SELECT label FROM venzo_clients WHERE label = '$san_label'") or die(mysql_error());

	if(mysql_num_rows($flabel) > 0) {
	
		$err['badlabel'] = "Label is in use";

	}

}


// more code below here

}[/php]

I have to check the table to make sure that they aren’t trying to use a label that already in use and because most of our clients couldn’t find their ass with detailed instructions.

Sponsor our Newsletter | Privacy Policy | Terms of Service