Jump to content

Paul-D

Members
  • Posts

    117
  • Joined

  • Last visited

Everything posted by Paul-D

  1. 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.
  2. 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
  3. 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(); ?>
  4. 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(); ?>
  5. What is needed is function prototypes complete with explanations. Prepare() and Execute() ???
  6. 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.
  7. 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']; }
  8. 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.
  9. 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>
  10. 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.
  11. Okay. I need a programmer who understands web based programming.
  12. 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>
  13. <html> <body> <? $Me = "James"; $Class = "French"; echo "My results are . " MySchoolResults($Me, $Class, $pdo); ?> </body> <html>
  14. 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>
  15. 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.
  16. 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.
  17. 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'); ?>
  18. This is waht I get when I supply m EXACTLY as he has given it to me. I get this error Warning: Missing argument 3 for LogMeX2(), called in /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/bank2/LogMe.php on line 74 and defined in /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/secure/SecurePDO.php on line 81 Fatal error: Call to a member function prepare() on a non-object in /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/secure/SecurePDO.php on line 84 And here is the entire code <?php error_reporting(E_ALL); ini_set('display_errors', '1'); define ('HOSTNAME1', 'mysql09.iomart.com'); define ('USERNAME1', 'otoogc692'); define ('PASSWORD1', 'mauritius'); define ('DATABASE1', 'otoogc692'); function connectDB() { static $pdo = null; if($pdo === null) { $host = HOSTNAME1; $user = USERNAME1; $pass = PASSWORD1; $MyDB = DATABASE1; $pdo = new PDO("mysql:host=$host; dbname=$MyDB; charset=UTF8", $user, $pass, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]); } return $pdo; } function Session_Init() { if (!isset($_GET['counter'])) $_GET['counter'] = ""; if (!isset($_SESSION['current_page'])) $_SESSION['current_page'] = ''; if (!isset($_SESSION['Event_Log'])) $_SESSION['Event_Log'] = ''; if (!isset($_SESSION['K9'])) $_SESSION['K9'] = ''; if (!isset($_SESSION['Survalance'])) $_SESSION['Survalance'] = ''; if (!isset($_SESSION["K208"])) $_SESSION["K208"] = ''; if (!isset($_SESSION["Error_1"])) $_SESSION["Error_1"] = ''; if (!isset($_SESSION["Error_2"])) $_SESSION["Error_2"] = ''; if (!isset($_SESSION["Error_3"])) $_SESSION["Error_3"] = ''; if (!isset($_SESSION["Error_4"])) $_SESSION["Error_4"] = ''; if (!isset($_SESSION["Error_5"])) $_SESSION["Error_5"] = ''; if (!isset($_SESSION["Current"])) $_SESSION["Current"] = ''; // Email Sessions if (!isset($_SESSION["Name"])) $_SESSION["Name"] = ''; if (!isset($_SESSION["Name2"])) $_SESSION["Name2"] = ''; if (!isset($_SESSION["Email"])) $_SESSION["Email"] = ''; if (!isset($_SESSION["Subject"])) $_SESSION["Subject"] = ''; if (!isset($_SESSION["Msg"])) $_SESSION["Msg"] = ''; } function FindMe() { $CookiePresent = 0; if (isset($_COOKIE["Headquarters"])) { if($_COOKIE["Headquarters"] == "Bananarama") $CookiePresent = 1; } return $CookiePresent; } function LogMeX2($pdo,$username,$password) { $sql = "SELECT User, UserKey FROM LIBusersX WHERE UserN = ?"; $stmt = $pdo->prepare($sql); $stmt->execute([$username]); // 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($password,$row['UserKey'])) { // passwrod didn't match return false; } // username and password matched, return user id return $row['User']; } ?>
  19. mac_gyver. I can't put $pdo into the call to LogMeX"(). The web page is not supplying this connection as it does not know what a database is. I get missmatch. WEBPAGE: $user = LogMeX2($Name , $password); This is not going to work with the function function LogMeX2($pdo,$Name,$password)
  20. Forgot to add the code. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); define ('HOSTNAME1', 'mysql09.iomart.com'); define ('USERNAME1', 'otoogc692'); define ('PASSWORD1', 'mauritius'); define ('DATABASE1', 'otoogc692'); function connectDB() { static $pdo = null; if($pdo === null) { $host = HOSTNAME1; $user = USERNAME1; $pass = PASSWORD1; $MyDB = DATABASE1; $pdo = new PDO("mysql:host=$host; dbname=$MyDB; charset=UTF8", $user, $pass, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]); } return $pdo; } function Session_Init() { if (!isset($_GET['counter'])) $_GET['counter'] = ""; if (!isset($_SESSION['current_page'])) $_SESSION['current_page'] = ''; if (!isset($_SESSION['Event_Log'])) $_SESSION['Event_Log'] = ''; if (!isset($_SESSION['K9'])) $_SESSION['K9'] = ''; if (!isset($_SESSION['Survalance'])) $_SESSION['Survalance'] = ''; if (!isset($_SESSION["K208"])) $_SESSION["K208"] = ''; if (!isset($_SESSION["Error_1"])) $_SESSION["Error_1"] = ''; if (!isset($_SESSION["Error_2"])) $_SESSION["Error_2"] = ''; if (!isset($_SESSION["Error_3"])) $_SESSION["Error_3"] = ''; if (!isset($_SESSION["Error_4"])) $_SESSION["Error_4"] = ''; if (!isset($_SESSION["Error_5"])) $_SESSION["Error_5"] = ''; if (!isset($_SESSION["Current"])) $_SESSION["Current"] = ''; // Email Sessions if (!isset($_SESSION["Name"])) $_SESSION["Name"] = ''; if (!isset($_SESSION["Name2"])) $_SESSION["Name2"] = ''; if (!isset($_SESSION["Email"])) $_SESSION["Email"] = ''; if (!isset($_SESSION["Subject"])) $_SESSION["Subject"] = ''; if (!isset($_SESSION["Msg"])) $_SESSION["Msg"] = ''; } function FindMe() { $CookiePresent = 0; if (isset($_COOKIE["Headquarters"])) { if($_COOKIE["Headquarters"] == "Bananarama") $CookiePresent = 1; } return $CookiePresent; } function LogMeX2($name , $pwd1) { connectDB(); $Name = md5($name); $Pwd1 = md5($pwd1); $ret = 0; $qValid = $pdo->query("SELECT COUNT(*) FROM LIBusersX WHERE UserKey = '$Pwd1' AND UserN = '$Name'"); $total = $qValid ->fetchcolumn(); // Should only be 1 or 0. if($total == 1) { $qUser = $pdo->query("SELECT User FROM LIBusersX WHERE UserKey = '$Pwd1' AND UserN = '$Name'"); $rs = $qUser->fetch(); $ret = $rs['User']; // Should return 0 or id of the user. } return $ret; } ?>
  21. well I have done everything you sugested. I used a function ConnectDB() I used a static variable. but in the called routine function LogMeX2($name , $pwd1) I get Notice: Undefined variable: pdo in /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/secure/SecurePDO.php on line 87. This is what I got from Kicken yesterday 08:03 but by popular request renamed $pdo
  22. I was told that backslash was no longer used as an escape sequence but you need it if you have to insert an apostraphy into a database table like O\'Rilley. I have tried to delete this inserted code but it won't let me. Right click no delete. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); define ('HOSTNAME1', 'mysql09.iomart.com'); define ('USERNAME1', 'otoogc692'); define ('PASSWORD1', 'mauritius'); define ('DATABASE1', 'otoogc692'); function connectDB() { static $pdo = null; if($pdo === null) { $host = HOSTNAME1; $user = USERNAME1; $pass = PASSWORD1; $MyDB = DATABASE1; $conn = new PDO("mysql:host=$host; dbname=$MyDB; charset=UTF8", $user, $pass, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]); } return $pdf; } function LogMeX2($name , $pwd1, $Sector)fs { connectDB(); $Name = md5($name); $Pwd1 = md5($pwd1); $ret = 0; $qValid = $pdo->query("SELECT current FROM LIBusersX WHERE UserKey = '$Pwd1' AND UserN = '$Name'"); $total = mysql_num_rows($qValid); if($total == 1) { $qUser = $pdo->query("SELECT User FROM LIBusersX WHERE UserKey = '$Pwd1' AND UserN = '$Name'"); $rs = mysql_fetch_array($qUser); $ret = $rs['User']; } return $ret; } ?>
  23. Ok will stick with $pdo to see where code needs to change. I have been told or die() will not be supported in PHP7. So has been removed. This needs to change: $total = mysql_num_rows($qValid); What is the equivalent in PDO and fetching an array $rs = mysql_fetch_array($qUser); function LogMeX2($name , $pwd1, $Sector) // E101 { $Name = md5($name); $Pwd1 = md5($pwd1); $valid = 0; $ret = 0; $qValid = $pdo->query("SELECT current FROM LIBusersX WHERE UserKey = '$Pwd1' AND UserN = '$Name'"); $total = mysql_num_rows($qValid); if($total == 1) { $qUser = $pdo->query("SELECT User FROM LIBusersX WHERE UserKey = '$Pwd1' AND UserN = '$Name'"); $rs = mysql_fetch_array($qUser); $ret = $rs['User']; } return $ret; }
  24. He insisted that I had used $pdo myself. Can you tell me if this is compulsary and that $conn (which i have always used) is okay to use. He said that I have to put the connection at the top of the page and to pass the connection to the function. This canot work for me as I say next. You say you are nice frendly people so be nice not threaten "I am going to close this topic down." *** My original post which was to convert mysql to PDF recommended by Barand. I supplied this code originally which has a database object $conn not $pdo. He said Don't connect every time you perform a query. Connect once at the top of the script, storing the connection in $pdo. Does this mean you must not have a connection called $conn? I am using $conn all over the place. I was told to pass the connection to the function. The problem is that I have a special functions file with over 80 functions all requiring a database connection. I have calls to these functions all over my website with web pages that don’t understand databases and can not supply a database object. A web page simply wants to know how many customers I have so calls the function as $Totals = TotalCustomers(); My function is going to require a connection as TotalCustomers($conn) which is an agrument miss match. The only way I can see of doing this is to make repeated connection calls. function TotalCustomers() { connectDB(); // code; }
  25. yes but Barand cab't read. He used my first atempt and kept to it. He insists that I used $pdo in my code which I did not. He said that he would close my thread down. He clearly was giving me a bloody nose. I do't have the ability do do local host. and the errors I was getting said that $conn was not declared when it was. Looky for me, I got a more frendly helpful forum. Don't bother replying to this as it is closed down now and I wont see the nasty posts.
×
×
  • 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.