dimebag12 Posted February 16, 2009 Share Posted February 16, 2009 hi sorry if im asking in the wrong section i have a little problem with a php script i want to use url shortening service for myself on my own host so i searched alot and found the php script that is exactly what i want but there is a problem . the this script have ability to shorten the url and add automatic name or number to the shortened url or the user can define tag for its shortened url and now the problem while defining tag im not able to use some characters like / or . or _ so i need a help to modify the script so i can use those characters too when chosing tag for my shortened url i do not know php and have nobody to help me i searched alot in the script and i think this the line that need to be modified // Find last URL $result = mysql_query('SELECT id FROM shrt_urls WHERE custom=0 ORDER BY id DESC') or error('Query failed. '.mysql_error()); // Get its ID if ( mysql_num_rows($result) ) { $id = mysql_result($result,0,0)+1; } else $id = 1; // Loop through till we find a free ID (needs improving to reduce potential number of queries) while ( mysql_num_rows(mysql_query('SELECT 1 FROM shrt_urls WHERE id='.$id.' LIMIT 1')) ) $id++; $key = id2key($id); } else { $custom = 1; $key = clean($_POST['key']); // Check for forbidden characters if ( ! ctype_alnum($key) ) { $_SESSION['msg'] = 'Error: The new URL can only contain alphanumeric characters (a-z,0-9).'; localRedirect($return); } // Check chosen key is available $id = key2id($key); if ( mysql_num_rows(mysql_query('SELECT 1 FROM shrt_urls WHERE id='.$id.' LIMIT 1')) ) { $_SESSION['msg'] = 'Error: Sorry, the new URL you chose is already in use.'; localRedirect($return); hope ive guessed it write can someone help me remove this restriction ? thanks so much in advanced Link to comment https://forums.phpfreaks.com/topic/145398-help-on-modifying-script/ Share on other sites More sharing options...
printf Posted February 16, 2009 Share Posted February 16, 2009 Remove or modify this... if ( ! ctype_alnum($key) ) { $_SESSION['msg'] = 'Error: The new URL can only contain alphanumeric characters (a-z,0-9).'; localRedirect($return); } If you don't understand why, see ctype_alnum(); Link to comment https://forums.phpfreaks.com/topic/145398-help-on-modifying-script/#findComment-763297 Share on other sites More sharing options...
dimebag12 Posted February 16, 2009 Author Share Posted February 16, 2009 hi thanks for reply i tried removing that line but the problem is not solved in fact still the whole script is working okay but again when i want to define tag for shortened url with chracters like . or / this time it does not give me the same error as befor : The new URL can only contain alphanumeric characters (a-z,0-9). but it says : We could not complete your request. The following error was returned. Could not find the requested URL. some kind of undefined error whats wrong is that code related to some other varaiable ? is it not better that i modify it somehow rather than deleting it ? plz help me i really need this script thanks Link to comment https://forums.phpfreaks.com/topic/145398-help-on-modifying-script/#findComment-763314 Share on other sites More sharing options...
dimebag12 Posted February 16, 2009 Author Share Posted February 16, 2009 i do really need help about this can some one do this favor to me ?? Link to comment https://forums.phpfreaks.com/topic/145398-help-on-modifying-script/#findComment-763520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.