unveiledsolectveganraspiContactLog inRegister
  • solect
  • vegan
  • raspi
  • Contact

  • Register

Raspberry Pi

  • Front Page
  • Latest pages
  • Latest comments
  1. Raspberry Pi
  2. Server 128
  3. MariaDB
  4. Commands
  5. PHP
Posted on 07 Aug 2021 at 12:38 pm :: Last edit on 15/08/21 11:55 am

PHP

Trying to use php to manage the database via website.
It should be easy but ???

$dbname='nutrition';
$dbuser='~~~~~~~~~~~~~~~';
$dbhost='localhost:port_number';
$dbpass='###################';
$connect= new mysqli($dbhost, $dbuser, $dbpass, $dbname);
//check for errors
if ($connect->connect_errno) {
echo "Failed to connect to MySQL: " . $connect->connect_error;
}

Problems using old code. I had to use the Object Orientated Programming option of new mysqli() and append the port number to $dbhost


August 8th
Problem accessing a value by using a php variable [$cat_id]
Here is the code
"SELECT name FROM category WHERE id='".$cat_id."'";
and here is where I found the syntax, after some 16 hours ??
msdk.com/php/use-php-variable-in-a-select-like-query


August 9th
08:00 Getting to grips with the new mysqli and have populated category list ✓

1 comment

Comment from: roger

id=’".$cat_id."‘

id=something
but as the something is not plain characters it has to go in single quotes
id=’something’
as the something is a variable is has to be converted to simple characters which it can do

1. Assume $cat_id is text
2. but as it isn’t directly it has to go inside a concatenation of [text . variable .text]
hence the use of the double quotes to allow the concatenation to explode
3. We get ” the value of the variable”

08/08/21 @ 09:29 pm


Form is loading...

Content Hierarchy

  • Desktop OS 64
  • Server 128
    • Public Access
    • Apache2
    • MariaDB
      • Installation
      • Setup User
      • Create DB
      • Import SQL
      • Export DB
      • Editing DB
      • Commands
        • CLI
        • MariaDB->
        • PHP
    • VNC Server
    • Install B2evo
    • Email Server
  • Hardware
Advanced CMS

This collection ©2022 by roger • Contact • Help • Website engine

Cookies are required to enable core site functionality.