Jump to content

Markus1954

Members
  • Posts

    28
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Markus1954

  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");
  15. Will this work better ? $query = "INSERT NTO `Cars`.`inventory` (`VIN`, `YEAR`, `Make`, Model`, `TRIM`, `EXT_COLOR`, `INT_COLOR`, `ASKING_PRICE`, `SALE_PRICE`, `PURCHASE_PRICE`, `MILEAGE`, `TRANSMISSION`, `PURCHASE_DATE`, `SALE_DATE`) VALUES (`5FNYF4H91CB054036`, `2012`, `Honda`, `Pilot`, `Touring`, `White Diamond Pearl`, `Leather`, `37807`, NULL, `34250`, `7076`, `Automatic`, `2012-11-08`, NULL)"; if($mysqli->query($query) === TRUE { echo ("<p>Honda Pilot inserted</p>"); } else { echo "<p>Error inserting Honda Pilot:</p>".$mysqli->error; echo"<p>*********</p>"; echo $query; echo "<p>**********</p>"; } This is the complete section of code where the problem exists.
  16. OK I put parentheses around the echo and it still did not work. Like I said above there are echo statements in the book that have () and some that are just echo "this is going to be printed";
  17. The ending curly brace exists, I just didn't swipe it. In the book there are echo statements with both parentheses and no parentheses. I put the parentheses in this particular statement to see if it would work. In the book there are none.. I am learning from the book using apache, mysql and php 8 on my computer. I am not ready for hosting right now. When the time comes and I have a website ready I have an approach to do it on this computer.
  18. Hi All; I am stuck. I am getting an error in some code. First this is the error I am getting: Parse error: syntax error, unexpected token "echo" in C:\Apache24\htdocs\createdb.php on line 19 The code below is line 18 and 19. In the past I found that sometimes the line above the error is the problem. I don't see the problem and hope that someone can shed some light on where this problem is. If you want to see more code I will provide it. if($mysqli->query("CREATE DATABASE Cars")=== TRUE{ echo ("<p>DATABASE Cars created</p>"); Thanks for your help
  19. I think so. Not sure if they are installed mysqli should be by default. gizmola I am running windows 11.
  20. HI, If any of you remember me I have a new book on php. It uses phpmyadmin. I have created a folder htdocs/php admin/. I tried using loclahost/php admin/setup/config.php. Here is what I get: Composer detected issues in your platform: Your Composer dependencies require the following PHP extensions to be installed: mysqli, openssl. OK so how do I set these dependencies to on? I went to php.ini and removed the ;
  21. Look I have muscle spasms all over my body so I make lots of typos. I also don't have my full ability to concentrate. So I may not be all that clear. As for the book that was written in 2015 as long as the code works, I can try to update it to php 8. Barand, got it. Thanks everyone
  22. Hey GingerM, Where am I going to fine error_reporting(E_ALL) and ini_set('display_errors','1');
  23. While all of you are here I have another question. I am using php 8. There is a book called the joy of php published in 2015. Can I use this book with PHP 8?
×
×
  • 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.