Jump to content

Markus1954

Members
  • Posts

    28
  • Joined

  • Last visited

  • Days Won

    1

Markus1954 last won the day on December 22 2021

Markus1954 had the most liked content!

Markus1954's Achievements

Member

Member (2/5)

1

Reputation

  1. Apparently you people are having a problem with my shortcut. So here is the complete 2 files. This is the lab.php file:<?php declare(strict_types=1); require_once("dog.php"); $lab = new Dog; bool $dog_error_message = $lab->set_dog_name('Fred'); print $dog_error_message ? 'Name update successful<br/>' : 'Name update not successful<br/>'; bool $dog_error_message = $lab->set_dog_weight(50); print $dog_error_message ? 'Weight update successful<br/>': 'Weight update not successful<br/>'; bool $dog_error_message = $lab->set_dog_breed('Lab'); print $dog_error_message ? 'Breed update successful<br/>' : 'Breed update unsuccessful<br/>'; bool $dog_error_message = $lab->set_dog_color('Yellow'); print $dog_error_message ? 'Color update successful<br/>' : 'Color update not successful<br/>'; //Get properties $dog_properties = $lab->get_pr0perties(); list($dog_weight, $dog_breed, $dog_color) = explode(',', $dog_properties); print "Dog weight is $dog_weight. Dog breed is $dog_breed. Dog color is $dog_color $dog_color."; ?> this is the file with the class called dog.php: <?php declare(strict_types=1); class Dog { private int $dog_weight = 0; private string $dog_breed = "no breed"; private string $dog_color = "no color"; private string $dog_name = "no name"; function get_properties() : string { return "$this->dog_weight, $this->dog_breed, $this->dog_color"; } } ?>
  2. I have a class in the file dog.php. The class is in that file. I am using an Apress book called Learn PHP 8.
  3. This is new in php 8. the set is something you do when you have a class and want to restrict access to the class. This is the new way of doing things in php 8 that makes it more secure. This is the line that is currently getting the error message: syntax error, unexpected variable "$dog_error_message" in C:\Apache24\htdocs\Learn\lab.php on line 7 This is line 7 and 8 bool $dog_error_message = $lab->set_dog_name('Fred'); print $dog_error_message ? 'Name update successful<br/>' : 'Name update not successful<br/>'; According to the author a set method allows values to be passed into the method. Then the values are verified before updating the properties in the object.
  4. bool that everyone is concerned with is in the book. I put it there because the author put it there. I put in the missing apostrophe and the error moved to line 7. For those of you following along that would be the line with bool $dog_error_message. I am using a book for php 8.
  5. HI All; Trying to learn php 8 and running into problem with the book. The author and publisher are difficult to get errata and help. So I am here looking for help. I am getting an error message and it doesn't make any sense. Here is the error message. syntax error, unexpected variable "$dog_error_message" And here is some of the code that I wrote; require_once("dog.php"); $lab = new Dog; bool $dog_error_message = $lab->set_dog_name('Fred'); print $dog_error_message ? 'Name update successful<br/> : 'Name update not successful<br/>'; Any help is appreciated. By the way the error is pointing to the line that starts with bool Thanks Mark
  6. Apache is working and mysql is working. I rewrote the $mysql line and it did nothing. All my php files have a .php extension.
  7. By the way doesn't mysqlnd have mysqli in it?
  8. All of the following do not have a semicolon: bz2, mbstring, exif, mysqli, openssl, pdo_mysql. They are not listed in my phpinfo(). I noticed an error in my index.php file. It has this in it, <?php phpinfo(); ?> I got the err\or from the Apache error.log. I not see any mysqli errrors.
  9. the mysqli section does not exist. When I make chages to the php.ini file I restart Apache. Mysqli.dll does not have a semicolon in front or it.
  10. No, there is no section with the heading mysqli. C:\php8\ext has a lot of files in it. I have a file php_mysqli.dll. I also have a php_pdo_mysql.dll.. I am running a production environment.
  11. Maxxd, This is what is loaded in my config file: Loaded Configuration FileC:\PHP8\php.ini I don't know how to use pdo_mysql. I do know that I have to go into the config file. Also I have mysqlnd in phpinfo().
  12. Yes, I went into services and restarted Apache.
  13. By the way I am running php 8 on windows
  14. Hi All, I am trying to get the mysqli to work in a program i am copying from a book. I have removed the semicolon from the extension=mysqli. I also have extension_dir set to c:\php8\ext. I don't know what else to do. I am getting an error problem which is: Fatal error: Uncaught Error: Class "mysqli" not found in C:\Apache24\htdocs\Joy\createdb.php:6 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\Joy\createdb.php on line 6. Line 6 is the piece of code: $mysqli = new mysqli("mySQL", "USER", "p@SSWORD");
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.