jkewlo Posted May 24, 2010 Share Posted May 24, 2010 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 More sharing options...
marcus Posted May 24, 2010 Share Posted May 24, 2010 Why don't you just do... function create($url){ Link to comment https://forums.phpfreaks.com/topic/202694-notice-undefined-variable/#findComment-1062419 Share on other sites More sharing options...
jkewlo Posted May 24, 2010 Author Share Posted May 24, 2010 well I have tried that and no luck still running into the notice.. function create($url) { global $link; global $config; $chars = generate_chars(); while( !isUnique($chars) ) ........ Link to comment https://forums.phpfreaks.com/topic/202694-notice-undefined-variable/#findComment-1062423 Share on other sites More sharing options...
jcbones Posted May 24, 2010 Share Posted May 24, 2010 if(isset($_GET["u"])): Link to comment https://forums.phpfreaks.com/topic/202694-notice-undefined-variable/#findComment-1062443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.