[Solved] check value if null return 0 otherwise return the value

If you are sure for getting an integer for your $value[‘status’] you can cast it to integer, it would be shorter: // in case of null, casting will return 0 $status = $STATUSES[(int)$value[‘status’]]; 0 solved check value if null return 0 otherwise return the value

[Solved] How Secure Is This Login System? (Using Cookies In PHP)

Here’s a non-exhaustive list of problems/solutions: Your code is difficult to read because it is not properly indented. You should use prepared statemens to guard against SQL-injection. You give hints to hackers by having different error messages. When the username is correct and the password wrong you say: “Login/Password Incorrect :(“, but if the username … Read more

[Solved] i need a PHP code to find longest contiguous sequence of characters in the string

Since you’re looking for continuous sequences: $string = ‘aaabababbbbbaaaaabbbbbbbbaa’; $count = strlen($string); if ($count > 0) { $mostFrequentChar = $curChar = $string[0]; $maxFreq = $curFreq = 1; for ($i = 1; $i < $count; $i++) { if ($string[$i] == $curChar) { $curFreq++; if ($curFreq > $maxFreq) { $mostFrequentChar = $curChar; $maxFreq = $curFreq; } } … Read more

[Solved] Preg_match for a string key

The regex would be this: /^[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}$/ Regex explanation: Start regex expression /^ Capital A-Z and Numerical 0-9 [A-Z0-9] 5 long exactly {5} Dash between sets End expression $/ <?php $reg = ‘/^[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}$/’; $string = ‘YTMG3-N6DKC-DKB77-7M9GH-8HVX7’; preg_match($reg, $string, $matches, PREG_OFFSET_CAPTURE); print_r($matches); ?> 7 solved Preg_match for a string key

[Solved] How can I do select of all user referral id?

If you have the data in memory(which is problematic for a big table) $users = array( array(“id” => 1, “user_id” => 1 , “friend_id” => 2,), array(“id” => 2, “user_id” => 2 , “friend_id” => 3,), array(“id” => 3, “user_id” => 3 , “friend_id” => 4,), array(“id” => 4, “user_id” => 10, “friend_id” => 15,), … Read more

[Solved] don´t recognize variable of php

Your trying to access the value of age from a page( dos.php) but you posting it to (two.php) and your missing $_POST[‘age’]. one.php <HTML> <BODY> <FORM ACTION=”two.php” METHOD=”POST”> Age: <INPUT TYPE=”text” NAME=”age”> <INPUT TYPE=”submit” VALUE=”OK”> </FORM> </BODY> </HTML> two.php <HTML> <BODY> <?PHP $age = $_POST[‘age’]; print (“The age is: $age”); ?> </BODY> </HTML> 0 solved … Read more

[Solved] php mysql show row data to columns [closed]

Converting rows to columns is called pivot. Most common way to do this is using GROUP BY and functions like MAX or SUM. Create/insert queries CREATE TABLE t (`date` DATE, `bank` VARCHAR(4), `total` INT) ; INSERT INTO t (`date`, `bank`, `total`) VALUES (‘2017-02-01’, ‘BCA’, 2500000), (‘2017-02-01’, ‘CIMB’, 1500000), (‘2017-02-01’, ‘UOB’, 3750000), (‘2017-02-02’, ‘BCA’, 2100000), (‘2017-02-02’, … Read more

[Solved] Laravel Handle big web application like amazon? [closed]

There’s a site, https://stackshare.io/, that provides information about companies and its technologies. Also, it offers users to point out and vote on the best aspects of and certain tool. Lets use this site data to compare Laravel, Sympony, CakePHP and Zend Framework Laravel https://stackshare.io/laravel Has 1520 Votes, the most quantity of votes goes for: Clean … Read more

[Solved] We need a script to create a backup of all the files, database and email using third party Cpanel details in PHP

include “xmlapi.php”; $source_server_ip = “”; $cpanel_account = “”; // cPanel username $cpanel_password = ”; // cPanel password //Credentials for FTP remote site $ftphost = “”; // FTP host IP or domain name $ftpacct = “”; // FTP account $ftppass = “”; // FTP password $email_notify = ”; // Email address for backup notification $xmlapi = … Read more

[Solved] Object as attribute, get parent class

No implicit methods. You must notify the instance when that happens. See this example: class Beer{ private $ingredients = []; public function addIngredient(Ingredient $ing){ $this->ingredients[] = $ing; $ing->setOwner($this); } } class Ingredient{ private $owner; public function getOwner(){ return $this->owner; } public function setOwner($owner){ $this->owner = $owner; } public function hasOwner() : bool{ return isset($this->owner); } … Read more

[Solved] Preventing duplicates in the database [closed]

I update your code. <?php mysql_connect(“localhost”, “root”, “”) or die(mysql_error()); mysql_select_db(“database”) or die(mysql_error()); ?> <html> <head> <title>Student list</title> <link href=”https://stackoverflow.com/questions/11200978/stylesheets/public.css” media=”all” rel=”stylesheet” type=”text/css”/> </head> <body id=”background”> <table > <tr> <td><img src=” images/Picture3.png” width=”1300″ height=”150″/></td> </tr> </table> <table> <tr> <td id=”structure”> <? // check for post data if( isset($_POST[‘name’]) && isset($_POST[’email’]) && isset($_POST[‘shift’]) && isset($_POST[‘class’]) && … Read more

[Solved] What is the purpose of compiling css/scss? [closed]

I’m confused. The question title refers to compiling CSS/SCSS, the question refers to compiling PHP/HTML. Since you tagged the question with sass, I’m assuming you’re trying to ask why we need to compile SASS to CSS, instead of just being able to include the SASS file into our projects? If that is your question, it’s … Read more