PHP - 404 Based On Special Character In Url
Folks,
Requirement: I want a .htaccess level solution to 404 when the URL contains special characters other than mentioned in the below Rewrite rule: Code: [Select] RewriteRule ^([a-zA-Z0-9-!@#$^&*:"<>/?]{4,})\.html$ search.php?q=$1 [QSA,L] So, what i want is, i want to show a 404 when the URL contains anything other than "a-zA-Z0-9-!@#$^&*:"<>/?" What i have done: Code: [Select] RewriteRule ^([a-zA-Z0-9-!@#$^&*:"<>/?]{4,})\.html$ search.php?q=$1 [QSA,L] Problem: Its not working with Special characters but working only with English letters and Numerics in URL. Cheers Natasha T Similar TutorialsI need to pass info to a php script via link while ignoring the character '&' for example: mywebsite.com/myphp.php?info=thisInformation&thecharacter& is there anyway I can tell php to ignore the character '&' and just read it as text (cause I understand its a special character.. maybe something like in XML you can ignore the character & by using <![CDATA[ ]]> thanks!!! much appreciated!!! PS: this is a must.. since in the end I am passing links.. and urls.. that are like amazon.com/blah&blah hello; I have: mysql: utf8_general_ci index.php: header( ... UTF-8) index.php: <meta ... content-type ... UTF-8> index.php, mysql query procedu ... mysql_set_charset( utf8 , .. ) ... So, if I put a special character in my db, it WILL display correctly in index.php But, if I put the same character in a php variable, it is BAD ... diamond-shape with question mark inside Since my special characters work from the db, I would like to also use them in html (index.php ). am I missing anything? thanks for your time .. Shannon I'm having a problem that I didn't seem to have in the past... for some reason, it just popped up... or maybe I'm just noticing it. Anyway, I this in a field in a mysql database: "Here's a test." When I query the database and echo the text to the page with this code: Code: [Select] $result = mysql_query("SELECT question FROM signin WHERE email = '$email'") or die (mysql_error()); $row = mysql_fetch_row($result); $test = $row[0]; echo $test; This is the result: "Heres a test." Any ideas on why the apostrophe is not being displayed and how to fix it? I'm stumped. Thanks for any help. Hi people! I have a form with a select list where options are populated from a table in my db.. the string format is like this -> car - branch (ex. toyota - japan so on..) when viewing the options it displays correctly with the "-" but when i tried submitting the form which will be inserted into the db the "- branch" gets cut off.. i think i need to encode it but i don't know how to do it.. thanks for any reply! <form action="main.php?id=test.php" method="post"> <input name="name" type="text" /> <input name="submit" type="submit" value="Look Up" /> </form> <?php if(isset($_POST['submit'])) { $today = date("Y-m-d"); $pname = rawurlencode($_POST['name']); $xml_feed_url = 'http://api.eve-online.com/eve/CharacterID.xml.aspx?names='.$pname.''; The above works perfect until the user enters a character like ' to the box, how do I get it to pass the ' into the address? Thank you I have this code to pull the first few words from the body text to use as a title. But, when the body contains apostrophe, it shows on my title as '. I found the following code that's supposedly fixes the code. But, I can't figure out how. I need to add this: $return = = htmlspecialchars_decode(token_replace($output, 'node', $node), ENT_QUOTES); Or something similar ... to this: Code: [Select] $limit = 10; $text = $node->body[$node->language][0]['value']; $text = strip_tags($text); $words = str_word_count($text, 2); $pos = array_keys($words); if (count($words) > $limit) { $text = substr( $text, 0, $pos[$limit]); $text = trim( $text ); $text = rtrim( $text, '.' ); $text = trim( $text ) . '...'; } return $text; Thanks in advance. Hi guys, I did read allot of documentation on the internet about reading/writing/parsing an XML file. I ended up using the following code, because I really have large files (some about 200MB) and regular dom does not work: while ($xml->read()) { switch ($xml->nodeType) { case (XMLReader::ELEMENT): if ($xml->localName == "job") { $node = $xml->expand(); $dom = new DomDocument(); $n = $dom->importNode($node,true); $dom->appendChild($n); $job = simplexml_import_dom($n); The problem I have is a special character error in the xml file, error returned on this line: "$node = $xml->expand();" I am literally banging my head to the wall to find a simple solution to this. I already have a cleaning function, but that can be applied only after the code above. As the file is large, to clean it, I would have to use the same code above to work on partial content at once, so I would have the same special character problem when I would try to read and split the file. I bet I am not the first one to be in this situation, but after about 5 hours of searching on the internet, I cannot do it no more. And I am not a php expert to come up with a new idea. One other thing to do probably would be to split the file into multiple files, and read them after that, without using the XMLReader. But this would ask for a different application. If, for example, on a file where I have an error, I do the reading with simplexml, without using the XMLReader, I don't get the error. But I cannot use simplexml on the files, since file size is variable. I have to use a reliable method that works for all situations. Hopefully someone has an idea to this STUPID situation! Thanks.
Hi Hi guys, I am writing a "login" script that will be on my main page(I have it inside of <head></head> tags). I want it to take a user name and password, store it in a variable that is persistant with all pages on my website. Is that possible? How can I make a variable that will carry over to a page that doesn't have the original code? E,g, $Login = "alogin"; then when my client goes to a different page $Login still == "alogin"? I hope this is understandable. I am not writing a very advanced script, I just want the input form to store the users login name/password so he or she may access a section of the site that has more options available if they're logged in. Hi experts. I am received a GET variable into a page which is a id with a value as uuid:3242_2323_4444_9909_433/child_repeat[1]. Which is being used in my mysql query. So my query will be SELECT * from table_1 WHERE id = $id. However php is treating this string differently, my query fails, it says that it has a error near :3242_2323_4444_9909_433/child_repeat[1]. So it seems that its interpreting the colon as something else and removing the text before the colon. How do I make it so if I get the question right, I have access to view the next page? For example, if I get this question right in index-1.php correct, it would take me to index-2.php (like in the script below), but if you don't get the question correct in index-1.php, you cannot have access/view index-2.php. Why I need this? Well, if you change the URL http://--------/index-1.php to http://--------/index-2.php, you can easily go from index-1.php to index-2.php without having to answer the question correctly. index-1.php: <?php if(isset($_POST['submit'])){ $number = $_POST['number']; if ($number == "elephant"){ header("Location: http://localhost/index-2.php"); exit();} } ?> <html> <head> <title>PHP Test</title> </head> <b>LEVEL 1</b> <body> <p> <font face="Courier New">c291cmNl</font> </p> <br/></body> </html> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> Answer: <!-- "elephant" --> <input type="text" name="number" /><br /> </select> <input name="submit" type="submit"> </form> Thanks Code: [Select] $DB->query("SELECT id,name from ibf_members where name = '{$ibforums->input['to']}' LIMIT 1"); $e2 = $DB->fetch_row(); if ($e2['id']){ }else{ $std->Error2("Username doesn't exist dude"); } Ok, if I put in my username let's say 1of my users name is "$tabB" if I do that, it doesn't work is there a work around? I hope this is a fairly quick one, I've got a form I'm building where i may well have some special characters being inserted (accents mostly) now normally i would just pop in an HTML editor (TinyMCE) and let that deal with it. But i am looking to export this data as a CSV for use in excel, which means i can't afford to have HTML tags within the output. I am sure someone will have come across this before any suggestions? many thanks Matt |