[Solved] CakePHP 3.0 and new project [duplicate]

I’ve been working a lot with Cakephp 2, and i’m currently learning Cakephp 3. What I can say so far is: cakephp 3 introduces a lot a interesting new functionnalities (i won’t detail here, you can find many resources on internet for that). cakephp 3 is really a major release: many things have changed. Even … Read more

[Solved] mysql rows count by where clause

Try using this query – $query = mysqli_query(“SELECT subcommentid,COUNT(*) as count FROM table GROUP BY subcommentid ORDER BY count DESC;”); $result = mysqli_fetch_array($query); echo $result[‘subcommentid’].'<br/>’; //subcomment id echo $result[‘count’]; // number of rows If you want all, store in array – $results = array(); while($row = mysqli_fetch_array($query)) { $results[$row[‘subcommentid’]] = $row[‘count’]; } echo “<pre>”;print_r($results);exit; 2 … Read more

[Solved] Ip Restriction with .httacces [closed]

The 1000th time: NO, you can’t protect your website by IP restrictions. Attackers could use use proxies or spoof their IP’s. If you really encounter some sort of heavy traffic from one single IP, you could temporarily block this IP using a system-wide firewall rule (check iptables). Temporary because this IP will likely change frequently. … Read more

[Solved] How to do this: example.com/users/user1 [closed]

You need somthing like this? Not clear what is your requirement. Check this blog for more Rewriting example.com/user.php?username=xyz to example.com/xyz RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1 Refer htaccess2 tricks solved How to do this: example.com/users/user1 [closed]

[Solved] What PHP Script will do this function: [closed]

You have 2 options Fault: Your body of code below, caused a parse error and this is due to an unescaped quote in the word doesn’t Option 1: Change this body of text/code: echo ‘<!DOCTYPE HTML PUBLIC “-//IETF//DTD HTML 2.0//EN”> <html><head><title>401 Authorization Required</title></head><body> <h1>Authorization Required</h1> <p>This server could not verify that you are authorized to … Read more

[Solved] Select all rows but one [closed]

Use <> or != as an not equal to operator. SELECT * FROM member WHERE personID <> 123; SELECT * FROM member WHERE personID != 123; If you want to exclude multiple IDs: SELECT * FROM member WHERE personID NOT IN (1,2,3); 4 solved Select all rows but one [closed]

[Solved] If else condition in php [closed]

This code will display city if avaialable <?php $getCityQuery = mysql_query(“SELECT city FROM tbl_city_master WHERE id = “.$rs->city.””); if ($getCityQuery) $resultSetCityQuery = mysql_fetch_assoc($getCityQuery); ?> <?php if (resultSetCityQuery != null) echo “<strong>City-</strong>$resultSetCityQuery[‘city’]”; ?> 4 solved If else condition in php [closed]

[Solved] how to show div alternately

As I understand, you are asking how to determine the alternate divs for applying different styles. You should use CSS classes to give the divs alternate effect. .section{width:500px; height:200px;} .rightinfo{ float : right; } .leftinfo{ float : left; } .section img{width:402px; height:178px;} In your PHP code before while loop have a variable $style = 0; … Read more

[Solved] Convert c++ function to PHP?

You can use almost the same syntax in PHP as your C++ function does: function encryptDecrypt($toEncrypt) { $key= array( ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’ ); $key_len = count($key); $output = $toEncrypt; for ($i = 0; $i < strlen($toEncrypt); $i++) { $output[$i] = $toEncrypt[$i] ^ $key[$i % $key_len]; } return $output; } … Read more

[Solved] Search engine PHP return error [closed]

On line 33 you have $i++, but you haven’t initialised $i I expect you have a syntax error in your MySQL query. Try this: $query1 = mysql_query($query) or die(mysql_error()); which will display the SQL error which you’ll have to fix. More: Your SQL is susceptible to an injection attack. Make sure you escape your inputs … Read more

[Solved] How do i only remove “http://” and “http://www”? [closed]

You should not just use str_replace and using regular expressions seem overkill as well. Keep it simple and test for the beginning of the strings and just use the substring of what you actually want: function trimUrl($url) { if (strpos($url, ‘http://www.’) === 0) { return substr($url, 11); } if (strpos($url, ‘http://’) === 0) { return … Read more

[Solved] what is the proplem with my code? [closed]

You are accessing a variable that isn’t defined unless $_POST[‘name’] has been defined. Change the line if ($name == “”){ to if (empty($name)) { PHP will check to see if the variable is set before trying to access it and see if it’s empty using this function. See this doc for more info 2 solved … Read more