Jump to content

Paul-D

Members
  • Posts

    176
  • Joined

  • Last visited

Paul-D's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Don't understand what $amt = 1234.56; in this. I am in the UK. The line in the PHP here is 66. Thanks for your help. <?php // House contents Desmond O'Toole 2026-03-19 /* Add */ require ("../secure/SecurePDO.php"); session_start(); Session_Init(); $page = "Possesions Selection"; if(!isset($_SESSION["Pk"])) { header('Location: index.php'); exit; } $Pk = $_SESSION["Pk"]; if(KeyCheckX($Pk)== 0) { header('Location: index.php'); exit; } $pdo = connectDB(); $sqlContents = "SELECT * FROM `Contents` WHERE Cat = 0"; $stmt = $pdo->prepare($sqlContents); $stmt->execute(); ?> <html> <head> <meta http-equiv="refresh" content="600 url=index.php"> <title>Possesions</title> </head> <body> <h1><span style="color: #0000ff;">House contents</span></h1> <table border="1" width="850px" cellpadding="1"> <tr> <td width="200px"><b>Type</b></td> <td width="220px"><b>Make</b></td> <td width="150px"><b>Model</b></td> <td width="180px"><b>Serial</b></td> <td width="100px"><b>Cost</b></td> </tr> <?php $totals = 0; while($row = $stmt->fetch()) { $totals += (float)$row["Cost"]; ?> <tr> <td><?=$row["Type"]?>&nbsp;</b></td> <td><?=$row["Make"]?>&nbsp;</td> <td align="right"><?=$row["Model"]?>&nbsp;</td> <td align="right"><?=$row["Serial"]?>&nbsp;</td> <td align="right">£<?=$row["Cost"]?>&nbsp;</td> </tr> <?php }?> <tr> <td><span style="color: #0000ff;"><b>Total</b></span></td> <td></td><td></td><td></td> <td align="right"><span style="color: #0000ff;"> <b>£<?php echo $totals?> /* THIS LINE is currently £10230.51 </b> </span> </td> <tr> </table> </body> </html>
  2. Hi. I want to display a curreny with commas. I have looked on line and saw £totals.toLocaleString() but get. . . Fatal error: Uncaught Error: Call to undefined function toLocaleString() Or should I create a function to do this?
  3. Hi I use a domain hosting company easy space. When try to aceess this page http://desmond-otoole.co.uk/HC/Contents.php I get Looks like there’s a problem with this site http://desmond-otoole.co.uk/HC/Contents.php might have a temporary problem or it could have moved. Error code: 500 Internal Server Error <?php echo "Testing"; exit; }?> Confusing.
  4. Yes the form does have a pound sign to the left. It's just me copying and pasting that has happend. However if there is a way of escaping hitting a pound sign then how do I do that without some kind of javascript? And yes there are other dorm of using the £. I have this in the code. $Comment = str_replace ( "£", "&#163;", $_SESSION["DE_Comment"] ) ;
  5. Hi. I have 2 text boxes where I add money in to an account and money out. This works. But if I accidently put a £ into the text box which is not needed, I get an error. I decided to do a string replace but get an error if I put the £ symbol in. Surley this should be simple? It works fine when I leave the '£' out. $Comment_Name = $_SESSION['COMMENT_NAME']; $_SESSION['DE_MyReason'] = $_POST['Reason']; // Keep the default regardless $_SESSION['DE_Money_In'] = $_POST['MoneyIn']; $_SESSION['DE_Money_In'] = str_replace ("£","",$_SESSION['DE_Money_In']); $_SESSION['DE_Money_Out'] = $_POST['MoneyOut']; $_SESSION['DE_Money_Out'] = str_replace ("£","",$_SESSION['DE_Money_Out']); $_SESSION["DE_DD_Entry"] = $_POST['DD_Entry']; $_SESSION["DE_MM_Entry"] = $_POST['MM_Entry'];
  6. PHP manual https://www.php.net/manual/en/language.oop5.visibility.php <?php /** * Define MyClass */ class MyClass { public $public = 'Public'; protected $protected = 'Protected'; private $private = 'Private'; function printHello() { echo $this->public; echo $this->protected; echo $this->private; } } $obj = new MyClass(); echo $obj->public; // Works echo $obj->protected; // Fatal Error echo $obj->private; // Fatal Error $obj->printHello(); // Shows Public, Protected and Private
  7. Variables Like $Age and $TinsOfCatFood would not cause a php error. It makes for good reading and is widely used within the Visual C++ world. Yes, php is case sensitive and $Cat and $cat would be different. You just have to set a standard for your variables and keep to it. You can use the laid down php standard if you wish. Scope of a variable is defiantly important. If a class variable has to be accessed outside the class, it MUST be public. I am accessing the variable $Age but I also have a private variable, private string $Detals. This cannot be accessed outside the class but can be returned as a value from the calling function. I have in part is taken this from the PHP Manual https://www.php.net/manual/en/language.oop5.properties.php Here we have within a class public $var1 = 'hello ' . 'world' also we have public $var6 = myConstant; As for having a class Human.php this does make good sense but this was my first attempt at using php. I could also have a DefaultClasses.php with the main classes held within it. Microsoft do this. The only criticism I see is PHP does not allow function overloading which is a setback. All in all, this should not cause a php error only my C++ standards differ here. I am confused with your tags are you saying that in php you should start with <?php but leave out the closing ?> at the end? This is a definite NO NO.
  8. Even better? <?php Class Human { public string $Name =""; public float $Height = 0.0; public int $Age = 0; private string $Detals; public function __construct(float $Heiht, int $Age, string $Name = "Billy") { $this->Height = $Height; $this->Age = $Age; $this->Name = $Name; } function __destruct() { // nothing to see here } public function WhoAmI(): string { $Details = "Name:" . $Name . " Height:" . $Height . " Age:" . $Age; return $this->Details; } } $PersonA = new Human; $PersonA->$Name = "Philip"; $PersonA->$Height = 5.10; $PersonA->$Age = 24; echo $PersonA->WhoAmI; $PersonB = new Human(5.10, 52); echo $PersonB->WhoAmI // Name will be Billy ?>
  9. Noticed a few silly typos. Here is the latest. <?php Class Human { public string $Name =""; public float $Height = 0.0; public int $Age = 0; public function WhoAmI(): string { private string $Details = "Name:" . $Name . " Height:" . $Height . " Age:" . $Age; $this-> $Details; } } $PersonA = new Human; $PersonA->$Name = "Philip"; $PersonA->$Height = 5.10; $PersonA->$Age = 24; echo $PersonA->WhoAmI; ?>
  10. I have done lots of class in C++ which is a very long time ago. I have never attempted this in php. Here is what I was looking at. Please not too crital over this but I am interested in pulic and private variables and functions here. Do need to give values to the variables in the class? <?php Class Human { public string $Name =""; public float $Height = 0.0; public int Age = 0; public function WhoAmI() { private string $Details = "Name: . $Name . " Height:" . $Height . " Age:" . $Age; $this-> $Details } } $PersonA = new Human; $PersonA->$Name = "Philip"; $PersonA->$Height = 5.10; $PersonA->$Age = 24; echo $PersonA->WhoAmI; ?>
  11. Paul-D

    Unexpected';'

    Update on what I said previously. I am entering into a database table the following Date of entry plus strlen($View) . $test [Is this NULL] The result of $test = "NOT NULL"; if($View === NULL) $test = "NULL"; I have got 2025-09-22 (0) NOT NULL a string that is lenthe 0 and it is NOT NULL Sugestion was to use var_export() so I have tested this $View = $_SESSION['CounterValue']; echo "Value: " . var_export($View); exit; Result: ''Value: <nothing follows> In the php manual https://www.php.net/manual/en/function.var-export.php All I get is the contents of the variable nothing else. What was I suposed to see here? Type of variable[string]? IS NULL? value if exists all the under the bonnet info on this variable. All I got was nothing. What my method showd was, it is NOT NULL and a zero length string. Which is more information than I got from var_dump()
  12. Paul-D

    Unexpected';'

    As I said previously I can not use storedata(...) here. I am entering this data into a database table with the field value as Page as varchar(20). I have used this $test = "NOT NULL"; if($View === NULL) $test = "NULL"; And add this into the database field. When the problem re accours I can check the database.
  13. Hi I have an error on line $test = "NULL"; in function GetAllData($StartDate, $View) { $test = "NOT NULL"; if($View == NULL { $test = "NULL"; // error Parse error: syntax error, unexpected token ";" in /vhost/d/e/s/desmond-otoole.co.uk/www/bank2/secure/SecureFunctionsBankPDO.php on line 32 } StoreData($StartDate . " Len: " . strlen($View) . "- " . $test); // *** Store data to trap this error *** $pdo = connectDB(); if($View == 'Show' or $View == 'Show+' . if($View == NULL) //Desmond. or Desmond.. { $sqlAllData = "SELECT * FROM Bank_Data WHERE EntryDate > ? AND EntryDate <= DATE_ADD(?, INTERVAL 6 WEEK) ORDER BY EntryDate ASC, Output"; $stmt = $pdo->prepare($sqlAllData); $stmt->execute( [ $StartDate, $StartDate] ); return $stmt; } if($View == 'Total' or $View == 'Database' ) { $sqlAllData = "SELECT * FROM Bank_Data ORDER BY EntryDate ASC, Output"; $stmt = $pdo->prepare($sqlAllData); $stmt->execute(); return $stmt; } } Seems okay to me.
  14. Hi have a table structure that has been working for years. I decided to drop the table and start again with EventID being an auto numbering. Error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1364 Field 'EventID' doesn't have a default value in /vhost/d/e/s/desmond-otoole.co.uk/www/secure/SecurePDO.php:255 Stack trace: #0 /vhost/d/e/s/desmond-otoole.co.uk/www/secure/SecurePDO.php(255): PDOStatement->execute() #1 /vhost/d/e/s/desmond-otoole.co.uk/www/bank2/secure/SecureFunctionsBankPDO.php(29): StoreData() #2 /vhost/d/e/s/desmond-otoole.co.uk/www/bank2/Statement.php(137): GetAllData() #3 {main} thrown in /vhost/d/e/s/desmond-otoole.co.uk/www/secure/SecurePDO.php on line 255 Original structure: DROP TABLE IF EXISTS `EventLog`; CREATE TABLE IF NOT EXISTS `EventLog` ( `EventID` int(11) NOT NULL, `Date` date DEFAULT NULL, `Stamp` varchar(10) DEFAULT NULL, `IP` varchar(30) DEFAULT NULL, `Page` varchar(20) DEFAULT NULL, `Browser` varchar(120) DEFAULT NULL, `Hit` varchar(1) DEFAULT NULL ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; This used to work but I changed it to: `EventID` int(11) NOT NULL AUTO_INCREMENT, This hasn't worked but it was fine originaly befor. Can someone work this out please. .
×
×
  • 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.