Jump to content

Notice: Undefined variable:


jkewlo

Recommended Posts

Hey,  I cant seem to wrap my head around this.. pretty simple and I am experienced in PHP

 

I am working on a project to shorten url's

 

and I keep getting this god awful

 

Notice: Undefined variable: u in create.php on line 44

 

Line 44 consist of

if($_GET["u"]):

 

I have called "u" in my functions.php which is in these lines

function create()
{
global $link;
global $config;
$chars = generate_chars();
while( !isUnique($chars) )
{
	$chars = generate_chars();
}
$url = $_GET["u"];
$url = trim($url);
$url = mysql_real_escape_string($url);
if(!isThere($url))
{
	$q = "INSERT INTO `urls` (url, unique_chars) VALUES ('".$url."', '".$chars."')";
	//echo $q;
	$r = mysql_query($q, $link);
	if(mysql_affected_rows()):
		$q = "SELECT * FROM `urls` WHERE `url`='".$url."'";
		$r = mysql_query($q);
		$row = mysql_fetch_row($r);
		echo $config["domain"]."/".$row[2];
	else:
		echo "Sorry, some problem with the database. Please try again.";
	endif;
}
else
{
	$q = "SELECT * FROM `urls` WHERE `url` = '".$url."'";
	$r = mysql_query($q);
	$row = mysql_fetch_row($r);
	echo $config["domain"]."/".$row[2];
}
}

 

I know that the Notice is saying that it has not yet been called but It has in the functions.php and I cant seem to get my head wraped around it any help would be wonderful

 

Thank you in advanced

Link to comment
https://forums.phpfreaks.com/topic/202694-notice-undefined-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.