PHP

121K

Solutions

33K

Contributors

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

Share tech news, updates, or what's on your mind.

Sign up to Post

Can you please help me in that error.
screenshot.JPGscreenshot2.JPG
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'Credentials/credentials.php';
require_once ("Entities/CoffeeEntity.php");
$coffee = new CoffeeModel($db);

var_dump( $coffee->GetCoffeeTypes() );
var_dump( $coffee->GetCoffeeByType('sometype') );
require_once ("Entities/CoffeeEntity.php");

//Contains database related code for the Coffee page.
class CoffeeModel {

    private $db;

    public function __construct(\PDO $db) {
        $this->db = $db;
    }

    public function GetCoffeeTypes() {
        $stmt = $this->db->query("SELECT DISTINCT type FROM coffee");
		
        return $stmt->fetchAll();
    }

    public function GetCoffeeByType($type) {
        $stmt = $this->db->prepare("SELECT name, type, price, roast, country, image, review FROM coffee WHERE type LIKE :type");
        $stmt->execute(['%' . $type . '%']);
		
        return $stmt->fetchAll(PDO::FETCH_CLASS, 'CoffeeEntity');
    }

}
?>

Open in new window


<?php

require_once 'Controller/CoffeeController.php';
$coffeeController = new CoffeeController();

if(isset($_POST['types']))
{
    //Fill page with coffees of the selected type
    $coffeeTables = $coffeeController->CreateCoffeeTables($_POST['types']);
}
else 
{
    //Page is loaded for the first time, no type selected -> Fetch all types
    $coffeeTables = $coffeeController->CreateCoffeeTables('%');
}

//Output page data
$title = 'Coffee overview';
$content = $coffeeController->CreateCoffeeDropdownList(). $coffeeTables;

include 'Template.php';
?>

Open in new window



Open in new window

0
Can you please help me in that error.
screenshot2.JPGscreenshot.JPG
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
class CoffeeEntity
{
    public $id;
    public $name;
    public $type;
    public $price;
    public $roast;
    public $country;
    public $image;
    public $review;
    
    function __construct($id, $name, $type, $price, $roast, $country, $image, $review) {
        $this->id = $id;
        $this->name = $name;
        $this->type = $type;
        $this->price = $price;
        $this->roast = $roast;
        $this->country = $country;
        $this->image = $image;
        $this->review = $review;
    }

}


?>

Open in new window

0
Can you please help me in that error.
screenshot2.JPGscreenshot.JPG
<?php
$user = "root";
$passwd = "";
$dsn      = 'mysql:host=localhost;dbname=coffeedb;charset=utf8mb4'; 
$options  = [
    PDO::ATTR_EMULATE_PREPARES   => false,
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
];

$db = new \PDO($dsn, $username, $passwd, $options);
?>

Open in new window


<?php
require 'Credentials/credentials.php';
$coffee = new CoffeeModel($db);

var_dump( $coffee->GetCoffeeTypes() );
var_dump( $coffee->GetCoffeeByType('sometype') );
require ("Entities/CoffeeEntity.php");

//Contains database related code for the Coffee page.
class CoffeeModel {

    private $db;

    public function __construct(\PDO $db) {
        $this->db = $db;
    }

    public function GetCoffeeTypes() {
        $stmt = $this->db->query("SELECT DISTINCT type FROM coffee");
		
        return $stmt->fetchAll();
    }

    public function GetCoffeeByType($type) {
        $stmt = $this->db->prepare("SELECT name, type, price, roast, country, image, review FROM coffee WHERE type LIKE :type");
        $stmt->execute(['%' . $type . '%']);
		
        return $stmt->fetchAll(PDO::FETCH_CLASS, 'CoffeeEntity');
    }

}
?>

Open in new window


<?php

class CoffeeEntity
{
    public $id;
    public $name;
    public $type;
    public $price;
    public $roast;
    public $country;
    public $image;
    public $review;
    
    function __construct($id, $name, $type, $price, $roast, $country, $image, $review) {
        $this->id = $id;
        $this->name = $name;
        $this->type = $type;
        $this->price = $price;
        $this->roast = $roast;
        $this->country = $country;
        $this->image = $image;
        $this->review = $review;
    }

}


?>

Open in new window

0
I am trying to pass in the value ASC to the database for a query but the error I get is:

Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''ASC''
Here is what I am sending via Ajax for testing:

var sort = 'ASC';
$.ajax({
        url: url + '/Admin/test',
        type: 'POST',
        dataType: 'json',
        data: {sort: sort}
    })

Open in new window


Controller:

    $data = [

        'sort' => $_POST['sort']
    ];

$reminders = $this->Model->Sort($data);

Open in new window


DB Query:

$this->db->query("SELECT fields
FROM tables
ORDER BY name :sort ");
$this->db->bind(":sort", $data['sort']);
$results = $this->db->resultSet();
return $results;

Open in new window

0
Good morning all !

Excuse me for my question but is there any way to have this same result in a more optimized code?

<table class="table table-striped table-hover table-bordered table-sm mb-3" id="Tableau_3">
<thead class="thead-dark">
<tr>
<th scope="col">Joueur</th>
<th scope="col">SIV gagnés</th>
<th scope="col">SIV utilisés</th>
<th scope="col">SIV expirés</th>
<th scope="col">SIV restants</th>
</tr>
</thead>
<tbody>

<?php
$WINS = 0;
$USED = 0;
$EXPI = 0;
$REST = 0;

$MyPDO_1 = $pdo->query("SELECT NIC_Handle, SUM(Points) AS SIV FROM tb_jeu_recap GROUP BY NIC_Handle"); while($data_1 = $MyPDO_1->fetch(PDO::FETCH_ASSOC)){
$NIC_Handle = $data_1["NIC_Handle"];
$WINS  		= $data_1["SIV"];

$MyPDO_2 = $pdo->query("SELECT SUM(Points) AS SIV FROM tb_jeu_recap WHERE NIC_Handle='".$NIC_Handle."' AND Retrait='OUI'"); while($data_2 = $MyPDO_2->fetch(PDO::FETCH_ASSOC)){
if($data_2["SIV"] == NULL) {$USED = 0;} else {$USED = $data_2["SIV"];}

$MyPDO_3 = $pdo->query("SELECT SUM(Points) AS SIV FROM tb_jeu_recap WHERE NIC_Handle='".$NIC_Handle."' AND D_Expire <= NOW()"); while($data_3 = $MyPDO_3->fetch(PDO::FETCH_ASSOC)){
if($data_3["SIV"] == NULL) {$EXPI = 0;} else {$EXPI = $data_3["SIV"];}

$REST 		= $WINS - $USED - $EXPI;
?>

<tr>
<td align="left"><?php echo $NIC_Handle; ?></td>
<td width="120" align="right"><?php echo $WINS; ?></td>
<td width="120" align="right"><?php echo $USED; ?></td>
<td width="120" align="right"><?php echo $EXPI; ?></td>
<td width="120" 

Open in new window

0
Hello
I want to free my future site's visitors from having to fill out the form before submitting their name, e-mail and a phone No. Basically, in most cases it won't be needed for them to also add more information in the form's text box. But the default (current) status is that they must at least type a single word before they're allowed to submit the form. I'll attach screenshot to better clarify the issue and also provide a link to a live site where you can see it in a real life situation.

https://www.profilecreations.co.za/index.php/products/desktop-stationery/blockpads/pvc-blockpad-detail

It's a Joomla's Virtuemart shop. Latest Joomla version and VM3 working together. In a product detail page there's an "Ask A Question" button. After it's clicked, you get a contact form, in which one can input their contact info and fill out the text box below and press "Send your question" button just below. My goal is just to directly contact the potential client by using their e-mail or a phone number. I don't need them to necessarily provide me with more information in that text box rectangle.  What I know so far is that there's a Virtuemart controller PHP file that makes sure that the required text box is filled out before the form's submission. This one: components/com_virtuemart/controllers/productdetails.php I'll also attach it to this post. It must be modified so that there wouldn't be a requirement of filling out that text box befere one can submit the form. Here's the …
0
Can you please help me in that error.
screenshot.JPGscreenshot2.JPGscreenshot3.JPG
<?php

require ("Entities/CoffeeEntity.php");

//Contains database related code for the Coffee page.
class CoffeeModel {

    //Get all coffee types from the database and return them in an array.
    function GetCoffeeTypes() {
        require 'Credentials.php';

        //Open connection and Select database.   
        mysql_connect($host, $user, $passwd) or die(mysql_error());
        mysql_select_db($database);
        $result = mysql_query("SELECT DISTINCT type FROM coffee") or die(mysql_error());
        $types = array();

        //Get data from database.
        while ($row = mysql_fetch_array($result)) {
            array_push($types, $row[0]);
        }

        //Close connection and return result.
        mysql_close();
        return $types;
    }

    //Get coffeeEntity objects from the database and return them in an array.
    function GetCoffeeByType($type) {
        require 'Credentials.php';

        //Open connection and Select database.     
        mysql_connect($host, $user, $passwd) or die(mysql_error);
        mysql_select_db($database);

        $query = "SELECT * FROM coffee WHERE type LIKE '$type'";
        $result = mysql_query($query) or die(mysql_error());
        $coffeeArray = array();

        //Get data from database.
        while ($row = mysql_fetch_array($result)) {
            $name = $row[1];
            $type = $row[2];
   

Open in new window

0
I want to be able to insert a user into the user table Laravel creates by default as a result of "php artisan auth." Basically, I'm adding a column to that table that gives my user administrative privileges.

I've got it done, for the most part, but there's one thing that keeps alluding me: I want to be able to create a "request" file where I can document some validation rules. When I do that, I get some errors and I'll elaborate on that in just a minute.

The one thing I've found recently is that when you look at the User model, you see this:

<?php

namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

Open in new window


From what I gather, "authenticatable" is going to invoke some validation rules by default. On top of that, when you look at the Controller that is made by the "auth" command, you see this:


Open in new window

0
Dear Experts,
I want to post the data with POST method, I use below code used to be working, however it is not working now. They say, my code is GET method not POST method, that is why it is not working.

How can I convert my code to POST method? thank you

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"THE-URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
            "VALUE1=&resultUrl=json&referenceCode=$referans");


// Receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec($ch);

Open in new window

0
Here's the error:

Too few arguments to function App\Http\Controllers\UserController::store(), 0 passed and exactly 1 expected

Here's my Controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
//use App\Http\Requests\CreateUserRequest;

class UserController extends Controller
{
	
	  public function __construct() {
        $this->middleware('checkRole: admin');
    }
	
    public function index()
    {
        $users = User::all();
		return view('admin/listUsers', compact('users'));
    }

   public function insertUser() {
        return view('admin.insertUser');
    }

   public function store($request)
    {
		$user = new User;
		if($input('admin_yes')=="Y") {
			$user->admin=1;
		}
		else {
			$user->admin=0;
		}
		$user->id = $request->input('user_id');
		$user->name=$request->input('name');
		$user->email=$request->input('email');
		$user->password = Hash::make($request->input('password'));
		$success='User was successfully created!';
		
		if($user->save()) {
			return View::make('/admin/displayUser')
			->with('user', $user)
			->with('newUser', 'Here\'s the user you just entered!')
			->with('adminPermissions', 'yes');
		}
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return 

Open in new window

0
I am extracting data from a pdf and so far, it's has been going fairly decent. I am working in localhost, Win 10, WampServer and using PHP 5.6.25.
I am using PdfParser and used composer to install it. It was successful. I am trying to explode a line of data on whitespace and it simple will not do it. I have done this before without a problem. I know from experience, that what I view in I.E. - source view - may not be what it really is to me visually. They appear to be a whitespace(s), so I decided that I would count the number of whitespaces in order to create the correct length for exploding on properly, and it returns a count of zero. I have tried to replace the whitespace(s) with another character - * - and it will not do it. I have even tried using chr(32) to represent the whitespace(s).
Therefore, even though it "looks" like a whitespace, maybe it really isn't. But I have no clue as to what it is or how to resolve it.
Can someone guide/educate me about what to try next or how to resolve this ??
I have other lines of data that I will need to explode based on whitespaces in this project.
Below is the snippet of coding: I have also attached a snapshot of what it looks in the source pane of I.E.
	if ($strtype == 'account')
        	{
			// look for actnbr
                       $wrkBegChar = 'AccountNumber';
	               $wrkEndChar = 'USD';
	     	       $strBegPos = stripos($strSearchData , $wrkBegChar,1); 
	    	       $strEndPos = stripos($strSearchData,

Open in new window

0
I'm working on some code and I'm trying to pop the hood on the login logic.

I'm trying to track down the URL that's actually handling the SELECT that will query the database and I keep seeing this:

$_SERVER['LOGIN_URL']

I see it referenced in the code, but I've yet to locate where it's actually defined.

Having googled it, I get the impression that this is a fairly common piece of syntax.

What is it and were do you find it?
0
So I have a login area which only seems to work in Firefox

its setting the variables but I appear to be losing the session somehow

from the login page, I do an AJAX call to the login.php file which checks the database and the status of the user, if all is good, I return true and AJAX changes the page location to the secured area. at the top of each page in the secured area, I check for $_SESSION['userID'] if its not set or empty it brings you back to the login page which is happening in every browser except for firefox ???
0
I have been struggling for 2 days on trying to resolve a problem and need help. I am using localhost, Win10 and Wampserver.
My goal is to use pdftotext class for php and composer. I have been trying to follow the instructions at URL:
https://php-xpdf.readthedocs.io/en/latest/

Open in new window

The first problem was trying to install composer. I already have curl installed, PHP 5.6.25 installed but when I tried installing using their curl example :
# Install composer
curl -s http://getcomposer.org/installer | php
# Upgrade your install
php composer.phar install

Open in new window

it errored out.
So I installed Composer from the URL:
https://getcomposer.org/doc/00-intro.md

Open in new window

and selected 'developer' and from the cmd line, I executed composer -v. It appears to be installed correctly. (In my previous attempts, I used the option of everyone but thought better of it so I uninstalled it, reboot my computer and installed using developers mode.
The next step was to download the pdftotext.
I unzipped it to my project folder, made a folder ""php-xpdf/php-xpdf" and moved the contents of the bin32 to "php-xpdf/php-xpdf"
 folder in my project folder.
I noticed that the folders in the Vendor folder, log,monolog,php-console,psr all have a composer.json file.
This is URL for the xpdf:
http://www.xpdfreader.com/download.html

Open in new window


My project path is:
c:\wamp\www\PDFConvert

Open in new window

My Vendor folder path is:
c:\wamp\www\PDFConvert\Vendor

Open in new window


This is the original coding snippet recommended to me:

Open in new window

0
Hello,

I am coding a custom Wordpress query, I want my keyword field to search post title, content and meta_queries..  The meta_query portion is working fine, but it isn't searching title and content. here is my code

$args = array (
    'post_type'			=>'resources',
    'post_status'       => 'publish',
	'posts_per_page'    => 100,
    'order'      => 'ASC',
    'search'     => '*' . esc_attr( $this_key ) . '*',
    'meta_query' => 
	
           array(
			'relation' => 'OR',
				array(
					'key'     => 'feedback',
					'value'   => $this_key,
					'compare' => 'LIKE'
				),
			array(
				'key'     => 'bfi_steps',
				'value'   => $this_key,
				'compare' => 'LIKE'
			),
			array(
				'key'     => 'agency',
				'value'   => $this_key ,
				'compare' => 'LIKE'
   				 )
		
		
	)

);

Open in new window

0
Hi Experts

Could you point why this Laravel's method doesn't correctly save a new  needed column?

<?php

//  The method signature have to receive one more parameter:    $cnpj_grupo
    private function gravarRevenda($codigoFilial, $divisaoRevenda, $tamanhoRevenda, $razaoSocial, $cnpj,        $cnpj_grupo,      $gerente, $consultor){
       
   // Previous method call 
    //private function gravarRevenda($codigoFilial, $divisaoRevenda, $tamanhoRevenda, $razaoSocial, $cnpj, $gerente, $consultor){
     

      $hierarquia = Hierarquia::where('identificador',$divisaoRevenda)->first();
      $tamanho_revenda = TamanhoRevenda::where('identificador',$tamanhoRevenda)->first();
      $tipoparticipante = Tipoparticipante::where('identificador','REVENDA')->first();
      $revenda = User::where('login',$cnpj)->first();

      if (empty($revenda)){
          $revenda = new User();
          $revenda->login=$cnpj;
          $revenda->dataNascimento='1980-01-01';
          $revenda->tipoparticipante_id=$tipoparticipante->id;
          $revenda->statusparticipante_id=3;
          $revenda->sexo_id=3;
          $revenda->created_at=Carbon::now();   
      }

      if($codigoFilial != null && $codigoFilial != '')
        $revenda->numero_filial=$codigoFilial;

      $revenda->name=$razaoSocial;
      
      $revenda->cnpj=$cnpj;
      
      // EF Jan 2020
      file_put_contents('debug.log', 'CNPJ Grupo gravarRevenda =  '.$cnpj_grupo.PHP_EOL, FILE_APPEND);
      
	  //  *******  

Open in new window

0
Im posting 2 variables using formdata via ajax

my php does what it needs to do and then tries to re-direct header('location: someotherwebsite.com')

Ajax is returning an error. page does not re-direct

Im not expecting any results

what im basically doing in the script is unsetting session variables session_destroy() then moving them away from the current page back to the home page
0
1) I have a mysql query which works fine in PHP my admin .
2) The reuslt is a table with first and last name .
3) I am not allowed to create new tables so have all the info in the meta_data.
4) I wrote a mysql query which does what I want ,
5) In PHP I am able to run the queries with test vars (meaining without the mysql vars).

6 )The Question :
How do I pass in one variable a mysql query with multiple rows.
7) my php code loop which works with single sql statmens is(this is just the loop part as code is large:
(note this code works as it's requesting a set id).
$mysqli;
	/* check connection */
$getTodaysEventsFromLastPostID ="SELECT * FROM wp_postmeta WHERE post_id =267";
	if (mysqli_connect_errno()) {
		printf("Connect failed: %s\n", mysqli_connect_error());
		exit();
	}
	$QueryVar1= $mysqli->query("SELECT @post_id:= post_id FROM wp_postmeta WHERE meta_key LIKE 'etimeclockwp-in%'");
	$QueryVar2 =$mysqli->query("SELECT @uid:= meta_value FROM wp_postmeta WHERE  meta_key ='uid';");
	$totalQuery=$mysqli->query("SELECT  @post_id,@uid;");
	$query = $getTodaysEventsFromLastPostID ;
	$result = $mysqli->query($query);

	while($row = $result->fetch_array())
	{
		$rows[] = $row;
		//print_r($row);
	}

	foreach($rows as $row)
	{
		echo $row['0']."<br>";
	}

	/* free result set */
	$result->close();

	/* close connection */
	$mysqli->close();

Open in new window




7 )Pure mysql query is:

SELECT @surname:= meta_value FROM wp_postmeta WHERE meta_key = 'etimeclockwp_surname' AND post_id=@uid;
SELECT @name:= meta_value FROM wp_postmeta WHERE meta_key = 'etimeclockwp_name' AND post_id=@uid;
SELECT @name,@surname;

Open in new window

0
Hi Experts

Could you point why an Excell file read at browser (js) is obtained at PHP code as a tmp file?

Accordingly with:
img001
The JS code called (that produces the console showed above):

 
User.prototype.subirLote = function() {
 // Called to upload the file
   console.log('XXXX');
  $("#arquivoLote").trigger("click");
  
  arquivo = $("#arquivoLote").val();
  
// The name is empty
  console.log('Y ' + arquivo);

};

Open in new window


When this PHP code is called:
<? 
//------------------------------------------------------------
    public function subirLote(Request $request){
//------------------------------------------------------------  
      
      $arquivo=$request->file('arquivoLote');
	  
	  
*--- AT THIS POINT THE FILE IS RECEIVED AS: C:\xampp\tmp\php6669.tmp (OR SOMETHING LIKE)
file_put_contents('debug.log', 'Arquivo = '. $arquivo.PHP_EOL , FILE_APPEND);
*-----------------------------------------------------------------------------

      Config::set('excel.import.heading', 'slugged_with_count');
      Config::set('excel.import.startRow', 1);

      try{

        $arquivoUrl = AzureStorage::saveFile($arquivo,'arquivos');
    
        $planilha = Excel::selectSheets('Participantes')->load($arquivo)->toArray();
      
        $validacao = $this->validarArquivo($planilha);
        

        if(!$validacao["valido"])
		{  
   
          return response()->json(new Resultado(false,"",$validacao));
        }
        
        

Open in new window

0
Dear Experts,

I use PHP and get the data like below.

$obj  = json_decode($server_output);

echo $output= $obj->result;

//the out put is:
{"CancelReturnCode":0,"CancelReturnData":"VPS-50026","ReferenceCode":"991770","Jcode":"123456","TimeStamp":"13.01.2020 15:17:37"}
 
 How can I get the result of the Jcode? thank you
0
I need some advice/guidance/suggestions. I am using localhost,  Win 10 . both IIS and WampServer  (Apache 2.4.23) are running (each have their own listening ports), and have both PHP 5.6.25 and 7.0.10 installed. I sometimes do work with classical ASP. With all being said, I have the need to extract data from pdf files and insert the data into a db.
I thought it would be easier for me to convert them to XML documents. This needs to be achieved programmatically and not at the CLI level.
I have pretty much decided that Java would be good to use (although I am far more comfortable with PHP) and have already posted two questions concerning the project.
WHAT I think I need is to have a IDE for my Java. I normally use Notepad++ (and sometimes CodeIgniter) Would Netbeans IDE be good to use ??
I am not very versed with Java, I am better with PHP.
If anyone has any suggestions and/or pointers for me about any of this - I am all ears and listening.
Thank you.
0
Can you please tell me how to i fix that error?  Thanks.

SOMETHING IS WRONG HERE: function mysqli_fetch_all($result, MYSQLI_ASSOC)
Warning: mysqli_connect(): (28000/1045): Access denied for user 'HarrisK'@'ip-107-180-46-230.ip.secureserver.net' (using password: YES) in /home/hfll4ovlkhjz/public_html/config/db_connect.php on line 3
Connection error: Access denied for user 'HarrisK'@'ip-107-180-46-230.ip.secureserver.net' (using password: YES)
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/hfll4ovlkhjz/public_html/index.php on line 6

Fatal error: Uncaught Error: Call to undefined function mysqli_fetch_all() in /home/hfll4ovlkhjz/public_html/index.php:8 Stack trace: #0 {main} thrown in /home/hfll4ovlkhjz/public_html/index.php on line 8

Open in new window


<?php
	include('config/db_connect.php');
	// write query for all pizzas
	$sql = 'SELECT title, ingredients, id FROM pizzas ORDER BY created_at';
	// get the result set (set of rows)
	$result = mysqli_query($conn, $sql);
	// fetch the resulting rows as an array
	$pizzas = mysqli_fetch_all($result, MYSQLI_ASSOC);
	// free the $result from memory (good practise)
	mysqli_free_result($result);
	// close connection
	mysqli_close($conn);
?>

<!DOCTYPE html>
<html>
	
	<?php include('templates/header.php'); ?>

	<h4 class="center grey-text">Pizzas!</h4>

	<div class="container">
		<div class="row">

			<?php foreach($pizzas as $pizza): ?>

				<div class="col s6 m4">
					<div class="card z-depth-0">
						<img src="img/pizza.svg"class="pizza">
						<div class="card-content center">
							<h6><?php echo htmlspecialchars($pizza['title']); ?></h6>
							<ul class="grey-text">
								<?php foreach(explode(',', $pizza['ingredients']) as $ing): ?>
									<li><?php echo htmlspecialchars($ing); ?></li>
								<?php endforeach; ?>
							</ul>
						</div>
						<div class="card-action right-align">
							<a class="brand-text" href="details.php?id=<?php echo $pizza['id'] ?>">more info</a>
						</div>
					</div>
				</div>

			<?php endforeach; ?>

		</div>
	</div>

	<?php include('templates/footer.php'); ?>

</html>

Open in new window

0
Hi Experts,

In my WP, I have a custom theme, and to load FA 4.7.0 I start off as :

<!DOCTYPE html>
<?php
    $theme_url = get_theme_file_uri();
    $main_url = get_home_url();
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        
        <link rel="stylesheet" id="mpc-style-css" 
              href="<?php echo $theme_url; ?>/style.css" type="text/css" media="all">
        
        <style>
            /* FONT PATH
 * -------------------------- */
@font-face {
  font-family: 'FontAwesome';
  
  src: url('<?php echo $theme_url; ?>/fonts/fontawesome-webfont.eot?v=4.7.0');
  src: url('<?php echo $theme_url; ?>/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), 
       url('<?php echo $theme_url; ?>/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), 
       url('<?php echo $theme_url; ?>/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), 
       url('<?php echo $theme_url; ?>/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), 
       url('<?php echo $theme_url; ?>/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
  
  font-weight: normal;
  font-style: normal;
}
        </style>
        
        <link rel="stylesheet" id="fa-css" 
              href="<?php echo $theme_url; ?>/font-awesome.css" type="text/css" media="all">
                
    </head>

Open in new window


Where, Lines 19-29 I moved from the original font-awesome.css just to get the path right.  This works, but as now I would like to use new icons, like fas fa-cross, I downloaded FA 5.12.0, but I don't know how to go about it and upgrade?

I see there more .css and font files, and the font-awesome.css file does not start with the src statements as the old one did.

Please note, I'm using a theme from scratch for very specific purposes, and don't want to get into why. I just need to upgrade FA

Thanks in advance.
0
Can you please tell me why its not showing a create button next to databases?  Thanks.
screenshot.JPG
0
Can you please help me in that error?  Thanks
Error: MySQL shutdown unexpectedly.

XAMPP MySQL Error
InnoDB: using atomic writes.
2020-01-11 16:01:51 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2020-01-11 16:01:51 0 [Note] InnoDB: Uses event mutexes
2020-01-11 16:01:51 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-01-11 16:01:51 0 [Note] InnoDB: Number of pools: 1
2020-01-11 16:01:51 0 [Note] InnoDB: Using SSE2 crc32 instructions
2020-01-11 16:01:51 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M
2020-01-11 16:01:51 0 [Note] InnoDB: Completed initialization of buffer pool
2020-01-11 16:01:51 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=300288
2020-01-11 16:01:59 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2020-01-11 16:01:59 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2020-01-11 16:01:59 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-01-11 16:01:59 0 [Note] InnoDB: Setting file 'C:\xampp\mysql\data\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-01-11 16:01:59 0 [Note] InnoDB: File 'C:\xampp\mysql\data\ibtmp1' size is now 12 MB.
2020-01-11 16:01:59 0 [Note] InnoDB: Waiting for purge to start
2020-01-11 16:01:59 0 [Note] InnoDB: 10.4.11 started; log sequence number 300297; transaction id 171
2020-01-11 16:01:59 0 [Note] InnoDB: Loading buffer pool(s) from 

Open in new window

0

PHP

121K

Solutions

33K

Contributors

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.