
Paul-D
Members-
Posts
150 -
Joined
-
Last visited
Everything posted by Paul-D
-
My website has worked for 15 years under mysql noew under php 8 I have to convert queries to PDO. My question is do these functions return any form of error code that can be examined. I have suaght help on this in this forum before but as I am new to PDO I need advice on trapping any PDO errors. $stmt = $pdo->prepare($sqlAllData); $stmt->execute(['StartDate' => $StartDate]); '' and in the main page $stmt = GetAllData($Date); while($row = $stmt->fetch()) { } TIA
-
all the PHP code together in one file. I can't see anything that is wrong with the PDO code here. It seems like the call to $stmt = GetAllData($Date); FAILS but it should not fail. It didn't under PHP 5.4 My-PDO connections .txt
-
I changed the information in my uploaded file but I beleive the folder is secured. and has been for a long time now. SecureFunctions/
-
mac_gyver pointed out that I am not using <?php in the statment.php I have corrected this as for opening the connection every time. I was told to do this . . . connections.txt And the web page has changed now because of <?php added Still does not like fetch() that is the bug in the system think. I was helped 6 months ago when trying to change the site to PDO. I am not mixing mysql with PDO here and it did work under PHP 5.4. I think it my webserver host has done something here. Connection.txt
-
I am not ussing a secure type server if that is what you mean. I could not see any diffrences between your updated code on the first two functions except you removed the // error number and placed the opening brace at the end of the first line. It still does not work with that code. As for "secure/SecurePDO.php file that contains your PDO connection". I do have a file with all the database connection setiings in a seperate file which has worked under PHP 5.4. This functioned fine. So something dosn't work under PHP8. As for the mix of code mysql. I beleive all that has now been replaced with correct PDO codeing.
-
Here is the PHP info on the website server. Don't understand that part. Can you check that this part is atleast correct please. As for Ensure that the `connectDB()` function is correctly implemented and returns a PDO instance. If there's an issue with this function, it might affect the query execution.;' This worked fine under PHP 5.4 so it is calling the database correctly and supplying the data.
-
Okay. I have been out of programming a long time and was told that the website I was going to be upgraded to PHP8. I converted all my database queries to PDO. I assumed that the rest of the PHP would be fine. It apears not. It seems the problem is with my PDO which worked fine under PHP 5.4. I know this is not going to be a topic you would not want to get into but if I had some pointers at this level could work the rest out. Seems it does not like ... $pdo = connectDB(); $stmt = $pdo->query("SELECT * FROM Bank_config"); $row = $stmt->fetch(); return $row; This was actualy working under PHP 5.4 SecureFunctionsBank.txt Statement.txt
-
Hi. My host is upgraiding the server from PHP 5.4.45 to PHP 8. I am running Mysql MYSQL 5.5.62. Is this compatable or will I have to work with new drivers. I will be moving from MYSQL 5.5.62 to 5.7.4-43 mysql_query() and mysql_query(). I was told to upgrade this to PDO and have changed my coding to $pdo = connectDB(); $pdo->query(). I have just been told that it is going to be upgraded to MySQLi so my newly created PDO will not work. Will my old mysql_query() still be valid or will I need to do imidate changes. I do not get a say in things like MySQL and PDO.
-
Hi. I am trying to use FTP on my android phone as sending emails with videos has a size limit. I use FileZilla on my PC. When I when to the google store it pointed me add AndFTP. I have managed to download files but I am struggling to upload files from my DCIM folder. I can’t send large videos but I should be able to upload to my website MySQL. I can’t navigate with the upload setting. Also I would like to choose the download folder. Can anyone help here or suggest a better android FTP. I am still on the free version at the moment. Thanks. Desmond.
-
The error is Warning: PDOStatement::execute() expects parameter 1 to be array, string given in /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/music2/musicX.php on line 37
-
My server is still PHP4.5 as such I am using md5(). I know this should be changed. Md5() is still supported in PHP7 so I can address the issue then. I need to do 2 things return a set of records from a table preferably using prepare and execute. I need to return a record from an admin table to check at log in. I need the entire row including access levels and last time logged in. I am interested in this bindParam(1, $Name); as I think this could be useful. What I have using prepare and execute needs help with. So any corrections to this would be very helpful. <? $pdo = connectDB(); $Name = "Bruce"; $sql= ("SELECT * FROM PDO WHERE Name_F = ?"); // $Name goes here $stmt = $pdo->prepare($sql); // $stmt->bindParam(1, $Name); $stmt->execute($Name); while ($row = $stmt->fetch()) { echo $row['Name_F'] . " - " . $row['Name_S'] . " - " . $row['DOB'] . "<br>"; } echo "Music count = " . $stmt->rowCount(); ?>
-
Hi. I have tried to use the prepare and execute on a sample table of people. This should returm to people with first name Bruce. Not sure what this bindParam is all about. Picked it up on an IBM PDO web site. <? $pdo = connectDB(); $Name = "Bruce"; $sql= ("SELECT * FROM PDO WHERE Name_F = ?"); // $Name goes here $stmt = $pdo->prepare($sql); // $stmt->bindParam(1, $Name); $stmt->execute($Name); while ($row = $stmt->fetch()) { echo $row['Name_F'] . " - " . $row['Name_S'] . " - " . $row['DOB'] . "<br>"; } echo "Music count = " . $stmt->rowCount(); ?>
-
What is needed is function prototypes complete with explanations. Prepare() and Execute() ???
-
The major problems with PDO there are no books on the subject just web pages with fragments of code. Back in the days of mySql there were and still are books you can buy.
-
I used MD5 in my database. I use UserKey instead off a password as I can have more than 1 word. A sentance even using any cahrtecter $%^&£@! That is why I used md5. Passord is the same as userkey. I even tested the sql and got one record. My record is found as UserN = 'a39e9eea66930fe0050d56a28bafab72' and UserKey = '44f1fa64d8974c18bcb9182286d3e2aa' function LogMeX2($name,$pwd1) { $Name = md5($name); $Pwd1 = md5($pwd1); $sql = "SELECT User, UserKey FROM LIBusersX WHERE UserKey = '$Pwd1' AND UserN = '$Name'"; echo $sql; // Returns 1 record Name = 'a39e9eea66930fe0050d56a28bafab72' UserKey is the Password = '44f1fa64d8974c18bcb9182286d3e2aa' $pdo = connectDB(); $stmt = $pdo->prepare($sql); $stmt->execute([$Name]); // fetch/test if a row was found, i.e. the username was found if(!$row = $stmt->fetch()) { // username not found return false; } // username found, test password if(!password_verify($Pwd1,$row['UserKey'])) { // passwrod didn't match return false; } // username and password matched, return user id return $row['User']; }
-
one if you is telling me to not use mdy when it is needed in the database. one of you is changing $conn to $pdo. another is chaging userkey to password. One did tell me to use $pdo = connectDB which does work. Another tells me to add $pdo to the function which dosn't work. Nobody want's to stick with the code I supplied in to you. You want to answere using your own variable names.
-
okay ginerjm: solve this then. Nobody here can sort this out. The only way is the way I did it before. Each function makes it's own call. <html> <body> <? $Me = "James"; $Class = "French"; echo "My results are ". MySchoolResults($Me, $Class, $pdo); ?> </body> <html>
-
ginerjm: Because I have writen in .NET. THe elephant in the room is that nobody here knows about web based programming. A web page can not supply a connection object. The page with all the functions needds to work this out itself. I was hopping that someonr here could supply a way to use a function without adding a $pdo to the function. Seems that I was wrong.
-
Okay. I need a programmer who understands web based programming.
-
Just in case I get another bloody nose. so I corrected it. I notice you want talk about the elephant in the room here which is web based Programming. In Microsoft .Net a web page dosn't supply the connection. <html> <body> <? $Me = "James"; $Class = "French"; echo "My results are ". MySchoolResults($Me, $Class, $pdo); ?> </body> <html>
-
<html> <body> <? $Me = "James"; $Class = "French"; echo "My results are . " MySchoolResults($Me, $Class, $pdo); ?> </body> <html>
-
I can not do this $x = MySchoolResults($user, $class, $pdo); The web page would complain. What is this unknown variable $pdo. <html><body>include functions.php $User="Me"; $Class="French"; <?$x = MySchoolResults($User, $Class, $pdo); ?> </body></html>
-
I came here and got my head bitten off. The facts of life in any programming languages are, you CAN NOT call a function supplying 2 aguments when the called function requires 3 arguments. So $x = MySchoolResults($user, $class); function MySchoolResults($pdo, $user, $class) {} Sorry guys but that's a fact. Also web page programming is diffrent to desktop pc programms. Each web page is an individual who knows nothing about any other web page.
-
The way I had it before worked fine. EVERY function in the main functions page of functions established there own individual connection. I was told not to do that HERE. I have a connection function connectDB(). Unless all the other function on this page can have full global access to the static $pdo then this can not work. I can not supply this into the function because the hundreds of web pages can't supply $pdo as an argument as there is no connection object on all the web pages. Even if they did they would all be pointing to a diffrent memory location and a different connection object. $pdo as to be fully global if it is to avoid adding the $pdo to hundreds of web pages with each one having it's own connection.
-
And here is the other page that calls the function on line 68 <?php require("../secure/SecurePDO.php"); session_start(); Session_Init(); $UserName = $_SESSION['USERNAME']; $UserPWD = $_SESSION['USERPWD']; $_SESSION["Error_1"] = ""; $_SESSION["Error_2"] = ""; $_SESSION["Error_3"] = ""; $_SESSION["Error_4"] = ""; // if cookie set then //$Input = $_SESSION["Name"]; $Name = $_SESSION["Name"]; $password = $_SESSION["PWD1"]; $Listings = 0; if($Name == "Desmond.") { $Name = "Desmond"; $password = "Phil Collins"; echo "Works"; } if($Name == "Desmond..") { $_SESSION['CounterValue'] = "Show"; $Name = "Desmond"; $password = "Phil Collins"; } if($Name == "Desmond...") { $_SESSION['CounterValue'] = "Total"; $Name = "Desmond"; $password = "Phil Collins"; } if($Name == "Desmond+") { $_SESSION['CounterValue'] = "Database"; $Name = "Desmond"; $password = "Phil Collins"; } $Error = 0; if($Name == "") // Ckey { $_SESSION["Error_1"] = "Must enter user name"; $Error = 1; } if($password == "") // Ukey { $_SESSION["Error_2"] = "Must enter a User Key"; $Error = 1; } $Ret = FindMe(); if($Ret == 0) { $_SESSION["Error_2"] = "... Thats just silly"; $Error = 1; } $user = LogMeX2($Name , $password); // User if($Error == 1 || $user == "0" || $user == "-1") { header('Location: index.php'); exit; } // GOOD carry on $Pk = KeySetX(MINUTES,30); if($Input == "Desmond.") $Pk = KeySetX(MINUTES,60); $_SESSION["Pk"] = $Pk; // $_SESSION["Uk"] = GetUser($_SESSION["PWD1"]); $_SESSION["Uk"] = $user; if($_SESSION['Event_Log'] == "Yes") confirmation($_SESSION["Uk"]); // Update the Extras date fields $_SESSION["Error_1"] = ""; $_SESSION["Error_2"] = ""; $_SESSION["Error_3"] = ""; $_SESSION["Error_4"] = ""; SetMe(0); header('Location: Statement.php'); ?>