[Solved] PHP coding standards for user entered data [closed]

You should generally try to ‘escape’ all special characters when dealing with user supplied input. If you find certain characters are causing havoc with your system then you can remove them like so: <?php $BadChars = array( “‘”, // Single quote – can harm SQL queries “%”, // Percent sign – can harm SQL queries … Read more

[Solved] PHP web app is unsecure while I already used pashword hash for password protection [closed]

Are you talking about the Secure Socket Layer (SSL)? Make sure all your links are https://directory/folder/file.ext and not http://directory/folder/file.ext If you want the links to work with both a secure and non-secure web site, you can start your links with just the slashes and no protocol name and colon. //directory/folder/file.ext Edit: OPs problem had to … Read more

[Solved] Proper use of NULL in mysql query from php

NULL is a specific value, not a string literal. It should be passed to query directly, i.e. INSERT INTO `Schedule` (`ETA`,`STA`,`ATA`) VALUES (‘2013-08-28 12:30:00’, NULL, NULL); that means your PHP code should handle that and not enclose NULL-s: $timeFormatAndNull = function ($format) { return function($time) use ($format) { $time = strtotime($time); return $time ? strftime($format, … Read more

[Solved] Whats wrong with this $return?

You’ve got <?php ?> inside existing PHP code. You cannot nest <?php ?>. Since you are using double quotes, simple variables like $kinsource will be interpolated but the function call to get_bloginfo() will have to be concatenated in. Switch all other double quotes inside the string to single quotes. $return .= “<a href=”https://stackoverflow.com/questions/9354628/$kinsource” class=”lightbox” rel=”pics”><img … Read more

[Solved] PHP – Replace part of a string [closed]

Use a regular expression. str_replace will only replace static values. $RAMBOX = ‘hardwareSet[articles][123]’; $Find = ‘/hardwareSet\[articles\]\[\d+\]/’; $Replace=”hardwareSetRAM”; $RAMBOX = preg_replace($Find, $Replace, $RAMBOX); Output: hardwareSetRAM The /s are delimiters. The \s are escaping the []s. The \d is a number. The + says one or more numbers. Regex101 Demo: https://regex101.com/r/jS6nO9/1 If you want to capture the … Read more

[Solved] Need assistance with regards to htaccess

This should work: RewriteEngine on RewriteCond %{THE_REQUEST} ^(GET|POST)\ /FLSD/DSS/\?d=([0-9]+)\ HTTP RewriteRule ^ /FLSD/DSS/%2\? [R=301,L] RewriteRule ^FLSD/DSS/([0-9]+)/?$ /FLSD/DSS/?d=$1 [L] It will convert http://something.com/FLSD/DSS/?d=624 into http://something.com/FLSD/DSS/624/ 3 solved Need assistance with regards to htaccess

[Solved] syntax error, unexpected ‘:’

Try to not use goto, as much as you can. By using goto you will be lost in your own code, because you have to search each time where your goto is pointing. Here you can do what you want by writing : if (mysql_num_rows(mysql_query(“SELECT `id` FROM `players` WHERE `hash`=’$hash’ LIMIT 1”))!=0) { $hash=generateHash(32); } … Read more

[Solved] Merging several strings in PHP [closed]

Give that a go, Works for me <?php $test = array(); $test[]=”serverA”; $test[]=”serverA.something.com”; $test[]=”serverA”; $test[]=”serverB”; $test[]=”serverB.something.com”; $test[]=”serverC”; $test[]=”serverD.something.com”; sort($test); $final = array(); $temp = “#”; for($i=0,$count = count($test);$i<$count;$i++){ if(substr( $test[$i], 0, strlen($temp) ) == $temp) $temp = $test[$i]; else { $final[] = $temp; $temp = $test[$i]; } } //unset first unset($final[0]); //add in last $final[] … Read more