I am new to coding and i founded these code
setcookie("r4444", "", time() - 10);
and
setcookie("r4444", "1", time() + 10);
what it mean by + 10 sec and – 10 sec?
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
I am new to coding and i founded these code
setcookie("r4444", "", time() - 10);
and
setcookie("r4444", "1", time() + 10);
what it mean by + 10 sec and – 10 sec?
service start = 2022-04-29 02:30:00
service end = 2022-05-05 02:40:00
emergency = 02:00 – 03:00
Work in total emergency time === ????
I need PHP function.
ACF’s Google Map field via Oxygen’s Builder Google Maps element
Trying to add this but it not working. The error getting.
Google Maps Platform rejected your request. Invalid request. Invalid ‘q’ parameter.
Tried creating a function to retrieve the value but it seems not to working.
function get_raw_field( $field ) {
$map_location = get_field( $field );
return $map_location['address'];
}
ANY HELP WOULD BE HIGHLY APPRECIATED.
Thanks
I’m confused: I’m getting this error for an invalid number of parameters but I think the number is correct. There must be something I’m missing and I need your help figuring out what.
This is the array I want to INSERT … ON DUPLICATE KEY UPDATE:
$payable_data = array(
'projectID' => $_POST['projectID'],
'date' => $project_data['duedate'],
'vendorID' => $project_data['vendorID'],
'totaltopay'=> ($project_data['subprice'] * $project_data['units']),
'currency' => $project_data['currency'],
'paid' => '0'
);
Six items total. Then I build the UPDATE part of the query:
$update = "";
foreach($payable_data as $payable_key => $payable_value) {
$update .= " ".$payable_key." = ?,";
$update_values[] = $payable_value;
}
$update = substr($update, 0, -1);
Here’s my query (I use a function to create the ? placeholders):
$payableQuery = $db->prepare("INSERT INTO ".PAYABLES." (".implode(',', array_keys($payable_data)).") VALUES (".$options->placeholders($payable_data).") ON DUPLICATE KEY UPDATE".$update."");
And here I execute the query:
$payableQuery->execute($update_values);
Here’s a screenshot of the error:

It’s relatively easy to count the number of parameters – six. What is wrong then?
$latest_tracking_update_date = array_values($events)[0]->date; // returns: 28/03/2022
$date1 = new DateTime("Y-m-d","$latest_tracking_update_date");
$date2 = new DateTime("Y-m-d");
$interval = $date1->diff($date2);
// shows the total amount of days (not divided into years, months and days like above)
$test345 = "difference " . $interval->days . " days ";
I am trying to get the difference in days between now and $latest_tracking_update_date however this is not working. Any ideas?
When creating a class, should you create public vars and assign them like this:
class DomainService {
public $parsedUrl;
public $scheme;
public $host;
public function parse($url)
{
$this->parsedUrl = parse_url($url);
$this->scheme = $this->url['scheme'];
$this->host = $this->url['host'];
}
}
Usage:
$parsed = $domainService->parse($url);
$scheme = $domainService->scheme;
$host = $domainService->host;
Or should you chain methods like:
class DomainService {
private $parsedUrl;
public function parse($url)
{
$this->parsedUrl = parse_url($url);
return $this;
}
public function scheme()
{
return $this->parsedUrl['scheme'];
}
public function host()
{
return $this->parsedUrl['host'];
}
}
Usage:
$parsed = $domainService->parse($url);
$scheme = $domainService->scheme();
$host = $domainService->host();
I am making a registration page where the username and password goes to the tbl_login, and I want to put the other details like the fullname into another table named tbl_userinfo that has a foreign key which is the id of tbl_login.
$Select = "SELECT username FROM tbl_login WHERE username = ? LIMIT 1";
$Insert = "INSERT INTO tbl_login(username, password, usertype) values(?, ?, ?)";
$Insert2 = "INSERT INTO tbl_userinfo(fullname, purok, contactnumber) values(?, ?, ?)";
$stmt = $conn->prepare($Select);
$stmt->bind_param("s", $username);
$stmt->execute();
$stmt->bind_result($username);
$stmt->store_result();
$stmt->fetch();
$rnum = $stmt->num_rows;
if ($rnum == 0) {
$stmt->close();
//for insert into tbl_login
$stmt = $conn->prepare($Insert);
$stmt->bind_param("sss",$username, $password, $usertype);
//for insert into tbl_userinfo (i want to add this)
$stmt = $conn->prepare($Insert2);
$stmt->bind_param("sss",$fullname, $purok, $contactnumber);
if ($stmt->execute()) {
echo '<script type="text/javascript">';
echo 'window.location.href = "../loginform/index.php";';
echo 'alert("Account created! Redirecting to Login page");';
echo '</script>';
The $select and $insert already works but when I add the $insert2 query it doesn’t save in the database
I got stuck with a PDF-Document, which (among other fields) contains five larger multiline text-inputs. For all five fields the DefaultAppearance-parameter of the relevant widget says
/DA (/SimplonNorm 0 Tf 0 g)
Is this a bug, a feature, or an unintended slip by the person who designed this PDF-Form?
As a matter of fact, this font size zero would result in invisible text once the document gets printed. To my observation, different PDF-viewers/writers (firefox,chromium,ubuntu-document-viewer) seem to substitute this zero-value by an obviously arbitrary new font-size. This, in turn, results in different rendering of the input-field, depending on the tool by means of which the form-fields get filled.
I am working on a php-tool to automatically fill this form, and a bit unsure whether I just choose an arbitrary value myself, or whether we should additionally contact the government agency who designed it.
first of all, English is not my native language.
I’m learning OOP with PHP and it’s hard for me to do this exercise, I know it’s not the best way to learn but I need something to start with.
Attached exercise.
translation of the exercise:
Part 4 – Exercises with OOP Application No 19 (Geometric Figures) The GeometricFigure class has: all its protected attributes, a default constructor, a getter and setter method for the _color attribute, a virtual method (ToString) and two abstract methods: Draw (public) and CalculateData (protected). CalculateData will be called in the constructor of the corresponding derived class, its functionality will be to initialize the _surface and _perimeter attributes. Draw will return a string (with the corresponding color) forming the geometric figure of the object that invokes it (return a series of asterisks that model the object). Example:
* *******
*** *******
***** *******
Use the ToString method to obtain all the complete information of the object, and then draw it on the screen. Class Hierarchy:
Undefined variable $title at this code don’t know what’s the problem to it am a beginner to php
Class Book{
var $title; //attribute
function __construct($Atitle){
$this ->$title = $aTitle; // constructor variables
}
}
$book1 = new book("Harry Potter");
echo $book1->$title;
I need to update from PHP 7.3 to PHP 8.0 or PHP 8.1.
About composer.json php from ~ 7.3.0 to ^ 8.0, ext-phalcon from ^ 3.3.0 to 5.0.0 beta3 I think I have to update to
It changed as follows
cphalcon-3.3.0cphalcon-3.3.0cphalcon-3.3.0phalconmvcApplication.zep
/**
* Handles a request
*/
abstract public function handle();
cphalcon-5.0.0beta3cphalcon-5.0.0beta3cphalcon-5.0.0beta3phalconMvcApplication.zep
/**
* Handles a MVC request
*/
public function handle(string! uri) -> | bool
What should I specify for the uri?
How can I get the user id from session in javascript?
I was using this:
$( document ).ready(function() {
var sessionUserId = '<?php $_SESSION['user_id'] ?>';
alert (sessionUserId);
});
I have created a form that can be navigated between login and register user. I created one table in database using mysql for admin with one record only and multiple records for user table, so if for example I followed the method where user select his role (admin/user) upon login, then it is also easy for new users when they register new account, to define themselves as admin upon registration, how to make the login process using 2 tables admin and users from the same login form?
login.php
<?php
session_start();
$conn = mysqli_connect("localhost", "root", "", "finalproject") or die("<script>alert('Connection Failed.')</script>");
if (isset($_POST['submit'])) {
$username = mysqli_real_escape_string($conn, $_POST['username']);
$password = md5($_POST['password']);
$user_type = $_POST['user_type'];
$select = "SELECT * FROM users where username='$username' and password='$password'";
$result = mysqli_query($conn, $select);
if (mysqli_num_rows($query_run) > 0) {
$row = mysqli_fetch_array($result);
if ($row['user_type'] == 'admin') {
$_SESSION['admin_name'] = $row['name'];
header('location:admin_page.php');
} else if ($row['user_type'] == 'user') {
$_SESSION['user_name'] = $row['name'];
header('location:user_page.php');
} else {
$error[] = 'incorrect email or password!';
}
}
};
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Login</title>
</head>
<body>
<div class="container">
<form action="" method="POST" class="login-email">
<?php
if (isset($error)) {
foreach ($error as $error) {
echo '<span class="error-msg">' . $error . '</span>';
};
};
?>
<p class="login-text" style="font-size: 2rem; font-weight: 800;">Login</p>
<div class="input-group">
<input type="text" name="username" value="" required>
</div>
<div class="input-group">
<input type="password" name="password" value="" required>
</div>
<div class="input-group">
<button name="submit" class="btn">Login</button>
</div>
<p class="login-register-text">Don't have an account? <a href="register.html">Register Here</a>.</p>
</form>
</div>
</body>
</html>
register.php
<?php
$conn = mysqli_connect("localhost", "root", "", "finalproject") or die ("<script>alert('Connection Failed.')</script>");
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$full_name = $_POST['full_name'];
$email = $_POST['email'];
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
$phone_number = $_POST['phone_number'];
$work_duration = $_POST['work_duration'];
$ig_account = $_POST['ig_account'];
$state = $_POST["state"];
$postcode = $_POST['postcode'];
$city = $_POST['city'];
$gender = $_POST['gender'];
$age = $_POST['age'];
if ($password == $cpassword) {
$sql = "SELECT * FROM users WHERE email='$email'";
$result = mysqli_query($conn, $sql);
if (!$result->num_rows > 0) {
$sql = "INSERT INTO users VALUES ('$username','$full_name', '$email', '$password', '$phone_number', '$work_duration', '$ig_account', '$state', '$postcode', '$city', '$gender', '$age')";
$result = mysqli_query($conn, $sql);
if ($result) {
echo "<script>alert('Wow! User Registration Completed.')</script> " ;
header("Location: successregister.html");
$username = "";
$full_name = "";
$email = "";
$_POST['password'] = "";
$_POST['cpassword'] = "";
$phone_number = "";
$work_duration = "";
$ig_account = "";
$state = "";
$postcode = "";
$city = "";
$gender = "";
$age = "";
}
else {
echo "<script>alert('Woops! Something Wrong Went.')</script>";
echo $wrong = mysqli_error($conn);
}
} else {
echo "<script>alert('Woops! Email Already Exists.')</script>";
echo $wrong = mysqli_error($conn);
}
} else {
echo "<script>alert('Password Not Matched.')</script>";
echo $wrong = mysqli_error($conn);
}
}
else
echo "<script>alert('No session exist or session is expired. Please log in again')</script>";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Registeration</title>
</head>
<body>
<div class="container">
<form action="process.php" method="POST" class="login-email">
<p class="login-text" style="font-size: 2rem; font-weight: 800;">Register</p>
<div class="input-group" style="margin-bottom: 40px;">
Username:<input type="text" name="username" value="" required></input>
</div>
<div class="input-group" style="margin-bottom: 40px;">Full Name:
<input type="text" name="full_name" value="" required>
</div>
<div class="input-group" style="margin-bottom: 40px;">Email:
<input type="email" name="email" value="" required>
</div>
<div class="input-group" style="margin-bottom: 40px;">Password:
<input type="password" name="password" value="" required>
</div>
<div class="input-group" style="margin-bottom: 40px;">Confirm Password:
<input type="password" name="cpassword" value="" required>
</div>
<div class="input-group" style="margin-bottom: 40px;">Age:
<input type="text" name="age" value="" required>
</div>
<div style="margin-top: 40px; margin-bottom: 20px;">Gender:
<label for="f-option" class="l-radio">
<input type="radio" name="gender" tabindex="1" value="Male" style="margin-left:10px;">
<span> Male</span>
<input type="radio" name="gender" tabindex="2" value="Female" style="margin-left:20px;">
<span> Female</span>
</div>
<div class="input-group" style="margin-bottom: 40px;">Phone Number:
<input type="text" name="phone_number" value="" required>
</div>
<div class="input-group" style="margin-bottom: 40px;">Work Duration:
<input type="text" name="work_duration" value="" required>
</div>
<div class="input-group" style="margin-bottom: 40px;">IG Account:
<input type="text" name="ig_account" value="" required>
</div>
<div class="form-group" style="margin-bottom: 10px;">
<label >State:</label>
<select name="state" class="form-control" required>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
</div>
<div class="input-group" style="margin-bottom: 40px;">Postcode:
<input type="text" name="postcode" value="" required>
</div>
<div class="input-group" style="margin-bottom: 50px;">City:
<input type="text" name="city" value="" required>
</div>
<div class="input-group" style="margin-top:40px;">
<button name="submit" class="btn">Register</button>
</div>
<p class="login-register-text">Have an account? <a href="login.php">Login Here</a>.</p>
</form>
</div>
</body>
</html> ?>
I’m trying to add custom attributes to product label in woocommerce cart
Here’s what I’m using
add_filter( 'woocommerce_cart_item_name', 'woo_api_cart_item_name', 10, 3 );
function woo_api_cart_item_name($item_name, $cart_item, $cart_item_key){
(... some code)
if($status == "NEW"){
if(isset($cart_item["clientDesignURL"]))
{
$item_name.= " <span style='color:red;' >✕</span> <a style='color:white;' href='".$cart_item["clientDesignURL"]."' class='clientDesignURLButton'> Customize</a>";
}
else
{
$item_name.= "<p onclick='myCustomFunctionB()' class='clientDesignURLError'>-</p>";
}
}
else{
$item_name .= "<span onclick='myCustomFunctionA()' style='color:green;' class='".$cart_item["clientDesignID"]."'>✓ <img src='".$decoded_response->thumbUrl."'/></span>";
}
return $item_name;
}
I’m trying to add button next to every item in cart which does something in ajax. Problem is that woocommerce / wordpress removes “onclick” attribute.
I’ve tried other tags but all of them are removed. Browser inspector
Changing theme doesn’t work. I’ve checked all plugins and it didn’t work either.
Trying other tags like
doesn’t work (whole tag got removed)
I’m quite in a pickle with a code I need to generate a page. I’ll try to be as simple as possible to make everyone understands what I need to do.
I have a database of N numbers of elements as an XML file. From that file I need to generate a multipage. I need to have a maximum of 25 elements per page with Next and Previous buttons, but at the moment I’m stuck with generating functions to make it work.
For the moment I’ve done some coding to count how many items are in the XML array and generating the increments of 25, but I can’t go any further with my skills. I’ll leave here the code I’ve written.
'''
$xml = simplexml_load_file("SITE_URL/database.xml");
$page = intval($_GET['page']);
$id = 0;
$count = 0;
$ids = array();
$idI = 0;
$idIArray = array();
foreach($xml->gamecard as $id) {
$ids[] = $id;
}
//Count IDs and Pages
$count = count($ids) - 1;
$pages = $count / 25;
$pages = ceil($pages);
function StopCount() {
$pageurl = "SITE_URL/list.php?page=";
if ($page <= $pages) {
$page++;
$newurl = $pageurl . $page;
echo "<a href='" . $newurl . "'>Next</a>";
} else {
//null
}
}
function PopulatePage($id) {
$url = $id->url;
$img = $id->img;
echo '<a class="darken" href="' . $url . '"><img width="320" height="240" src="' . $img . '"></a>';
}
function CountIdForPage($idCount, $count, $idIArray) {
$idI = (($idI + 25) * $idCount) - 1;
if ($idI > $count) {
$idI = $count;
}
array_push($idIArray, $idI);
return $idIArray;
}
function ExplodeIdI($idIArray) {
//TO DO
}
//Elaborate value for generating subsequential IDs number
foreach (range(1, $pages) as $idCount) {
$idIArray = CountIdForPage($idCount, $count, $idIArray);
}
//Testing
print_r($idIArray);
'''
If someone could help, I’ll be really gratefull!