PHP Freaks » PHP Coding Help
84 FOLLOWERS
Do you need help with some code you wrote? Ask here! Discuss and share information on everything related to PHP coding.
PHP Freaks » PHP Coding Help
6h ago
I have the following code and yesterday this was working and now I get nothing sent to my browser...
<?php
ini_set('display_errors','1'); //only during development
ini_set('display_startup_errors','1'); //only during development
error_reporting(E_ALL); //only during development
$options=[
PDO::ATTR_EMULATE_PREPARES => false, // turn off emulation mode for "real" prepared statements
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, //turn on errors in the form of exceptions
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, //make the d ..read more
PHP Freaks » PHP Coding Help
6h ago
Ive modified the Simple PHP Shopping Cart from the phppot site but for some reason when the cart reaches 19 items it wont add anything else to it and i dont know why. Is their a limit within php how long a session array can be? Here is the code that adds each item to the array
$cartItems = Session::get("cart_item");
$itemArray = array( 'ItemDesc' => $_POST["ItemDesc"],
'ItemCode' => $_POST["ItemCode"],
'ItemQty ..read more
PHP Freaks » PHP Coding Help
2d ago
Hi all. I encountered a problem in my laboratory work on web technologies. When I use the php artisan migrate command I get the following error.
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for db failed: nodename nor servname provided, or not known (Connection: mysql, SQL: select table_name as `name`, (data_length + index_length) as `size`, table_comment as `comment`, engine as `engine`, table_collation as `collation` from information_schema.tables where table_schema = 'db' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED ..read more
PHP Freaks » PHP Coding Help
6d ago
Is it possible to get the number of rows returned when using a SELECT query and a statement?
$sql="SELECT * FROM users WHERE username=? AND password=? AND active=1";
$stmt=$db->stmt_init();
if ($stmt->prepare($sql)) {
$stmt->bind_param("ss",$uname,$pword);
$stmt->execute();
$stmt->bind_result($id,$username,$password,$level,$added,$edited,$active);
$stmt->fetch();
echo "Matched: ".$stmt->num_rows.'<br>';
echo "id: ".$id."<br>Added: ".$added."<br>";
$stmt->close();
The "Matched ..read more
PHP Freaks » PHP Coding Help
6d ago
It's been many years since I did any of this stuff and just getting back into it. I did think of posting this in the mysql section but it's more of a code problem. I have the following...
$db=new mysqli(host,username,password,database);
$sql="SELECT * FROM users WHERE username=? AND password=?";
$stmt=$db->stmt_init()
That last line where I call $db->stmt_init() I get an empty browser - absolutely nothing where I should have a load of HTML appear. I have written the rest (just in case it matters) which is:
if ($stmt->prepare($sql)) {
$stmt->bind_param("ss",$uname,$pword)
$st ..read more
PHP Freaks » PHP Coding Help
1w ago
Hey!
...
Is there any problem with using ..
$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
I use htmlspecialchars before on all my values already. Think of this as if i missed one.
Is it OK ..read more
PHP Freaks » PHP Coding Help
2w ago
I need a little clarity, as I have a form with input and want to sanitize the input effectively to avoid attacks and complications.
I adapted a W3 example but got unexpected results when I tried to view the results to verify success.
$data = trim($data); echo "after trim >".$data."<br>";
$data = stripslashes($data); echo "after strip >".$data."<br>";
$data = htmlspecialchars($data); echo "after char >".htmlspecialchars($data)."<br>";
echo "straight ".htmlspecialchars($data)."<br>"; //different viewable result
echo " >".$data."&l ..read more
PHP Freaks » PHP Coding Help
2w ago
Dear Team,
I am using Canvas grap on my PHP project. I am using PHP query on the same page and defining the as a variable on a script and passing the script to another js file.
My code is
$previous_month = date('Y-m', strtotime(date('Y-m') . " -1 month"));
$Year = date('Y');
$Mc = "SELECT Region, McTotal, McAssigned FROM
( SELECT count(a.BranchCode) as McTotal, c.regnName as Region FROM sbms.machinemaster as a
inner join sbms.branch as b on b.branchcode = a.BranchCode
inner join sbms.region as c on c.regnID = b ..read more
PHP Freaks » PHP Coding Help
2w ago
Hi All
Using MVC Model i am stuck on multiple dependent combobox, My first combobox model code is as follows
function getCompanyName(object $pdo){
$query = "SELECT * FROM MASTER_COMPANY;";
$companyNameStmt = $pdo->prepare($query);
$companyNameStmt->execute();
$companyNameresult = $companyNameStmt->fetchAll(PDO::FETCH_ASSOC);
return $companyNameresult;
}
I want to populate to a combobox
<select name="FCompName" id="company-id" class="form-select" required="">
<option value="" disabled selected>--- SELECT COMPANY ---</option> ..read more
PHP Freaks » PHP Coding Help
2w ago
Greetings,
I'm trying to build a system where the superAdmin can add users .
I have add_user.php
<!--begin::Form-->
<form role="form" method="post" action="insert/user.php" class="ajax" id="insert">
<div class="kt-portlet__body">
<div class="form-group row">
<div class="col-lg-6"> ..read more