[Solved] Undefined index (PHP)

[ad_1] It’s ternary. The syntax is var = (true) ? trueValue : falseValue; It’s the same as this: if ( empty($_POST[‘code’]) ) { $code = null; } else { $code = $_POST[‘code’]; } [ad_2] solved Undefined index (PHP)

[Solved] Take screenshot via PHP and Javascript

[ad_1] Lots of such screen capture web service here: What’s the best website screenshot capture API? But instead of doing that by yourself, I think you should go with those many public link-shortening service, like t.co, because anti-malicious is already one of their purpose: Having a link shortener protects users from malicious sites that engage … Read more

[Solved] How can I toggle a boolean number?

[ad_1] Your approach is correct and will work as well. Just you need to wrap it into a function. Another way is using ^ (Bitwise XOR) to do that functional and more clean: function toggleNumber( $num ) { return $num ^= 1; } Online Demo That function gets the number and does XOR with 1 … Read more

[Solved] Mysql insert into string value [duplicate]

[ad_1] If you’re using the deprecated mysql function: $user = “121”; $pass = “dummy1”; $email = “[email protected]”; mysql_query(“INSERT INTO users(username, password, email) VALUES(‘$user’, ‘$pass’, ‘$email’)”); On the other hand, using mysqli: mysqli_query($con, “INSERT INTO users (username, password, email) VALUES (‘$user’, ‘$pass’, ‘$email’)”); Note: where $con is the mysqli connection made variable. 3 [ad_2] solved Mysql … Read more

[Solved] send email is not working with bootstrap [duplicate]

[ad_1] I don’t think, this is your full code, but what I can see you have never set $_POST[‘sendemail’] so if(isset($_POST[‘sendemail’])) { will never be true. EDIT Just see the code below, I made 3 comments. <?php // 1. ————-↓ Change sendemail to submit if(isset($_POST[‘submit’])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to … Read more

[Solved] I have an array of dynamic data, how to display that with ordered list as mega menu

[ad_1] Couple of foreach loops should do the trick: <?php $arr = array( ‘properties’ => array( 0 => array( ‘sub’ => ‘hello’ ), 1 => array( ‘sub’ => ‘world’ ) ), ‘cars’ => array( 0 => array( ‘sub’ => ‘hello1’ ), 1 => array( ‘sub’ => ‘world2’ ) ) ); print_r($arr); echo ‘<ul>’; foreach ($arr … Read more

[Solved] PHP time period “7 days, 18:50:19”

[ad_1] strtotime can parse a “period” format like that natively, the only key point is to also pass in 0 as the second parameter so that the result is relative to the unix epoch rather than the current time: $seconds = strtotime(‘7 days 18:50:19’, 0); echo $seconds; 672619 0 [ad_2] solved PHP time period “7 … Read more

[Solved] Limit MySQL Results to X Days [duplicate]

[ad_1] Sure. Create a time window and you can limit by that date $time = time() – (86400 * 30); // 86400 seconds in one day $sql=”SELECT * FROM table WHERE datefield > “” . date(‘Y-m-d H:i:s’, $time) . ‘”‘; That should yield you records within the last 30 days 2 [ad_2] solved Limit MySQL … Read more