Vivid Lust Posted February 9, 2009 Share Posted February 9, 2009 Hi all, I made a script for a friend, it works find on my server but not on his (he uses PHP5) Code: <?php require("db.php"); //connect to mysql $link = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); //connect to db mysql_select_db($dbname,$link) or die ('Error connecting to mysql') or die(mysql_error()); $t = $_GET['t']; $sql ="SELECT * FROM tiny WHERE TinyUrl=\"$t\""; $query=mysql_query($sql, $link) or die(mysql_error()); while($row=mysql_fetch_assoc($query)){ $uri = $row['FullUrl']; } header("location: $uri"); ?> An error has occurred. On mine, the header part works fine, however on his, it seems not to do anything, but the page just displays the "An error has ocurred". As far as I know there is no other error in the script. Just some weird header thing ( for me) All help appreciated! Thanks guys - Jake. Quote Link to comment https://forums.phpfreaks.com/topic/144526-solved-header-not-redirecting/ Share on other sites More sharing options...
premiso Posted February 9, 2009 Share Posted February 9, 2009 One, queries use single quotes, not double: $sql ="SELECT * FROM tiny WHERE TinyUrl=\"$t\""; Should be $sql ="SELECT * FROM tiny WHERE TinyUrl='$t'"; That will cause an error. Two, it seems as though you expect more than 1 item returned, but you are only using the last item, try this: $sql ="SELECT `FullUrl` FROM tiny WHERE TinyUrl='$t'"; $query=mysql_query($sql, $link) or die("ERROR IN SQL {$sql} \n Mysql Reutrned: " . mysql_error()); $uri = mysql_result($query, 0); Change those items and see if it works. Quote Link to comment https://forums.phpfreaks.com/topic/144526-solved-header-not-redirecting/#findComment-758391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.