Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.