Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. But why the second page? The first page, with the search, should be able to do just that. It doesn't now because it's broken - like I mentioned. Try using your form but only searching by faculty...
  3. You're saying that carlos-meneses/laravel-mpdf is timing out? Maybe it was a glitch with packagist - it's doing fine here. There's only two additional packages it looks like. Now that you've removed it from the composer.json file, have you tried manually requiring it with `composer require carlos-meneses/laravel-mpdf`?
  4. Today
  5. The second page should display the specific name and correlating information related to that name. Example if I search "John Doe" the second page should display John Does information only such as his email address, gender etc. To which this information is received from a text file. The problem right now is that all entries in the text file are being displayed whether the name exists in the text file or not.
  6. If you want to use Laravel for something then you install just laravel/laravel and Composer will get the other dependencies - unless it can't reach GitHub in which case yes, you have to download all of those separately, and then download all of their dependencies, and so on. That is not going to be fun. And what about mpdf?
  7. Your search is broken. You want this second page to do what, exactly? You're already showing information for searched things: it's your search page.
  8. re: your last post above. if you are seeing the form, given that there are php syntax errors still present, it is likely that you are not requesting the page using a url -
  9. Here is your lastest code with some notes. But you REALLY SHOULD USE MAC_GYVER'S CODE. PDO is so much easier to use. // TURN ON ERROR CHECKING error_reporting(E_ALL); ini_set('display_errors', '1'); $host_name = 'xxxxxx'; $database = 'xxxx'; $user_name = 'xxxx'; $password = 'xxxx'; $link = new mysqli($host_name, $user_name, $password, $database); if ($link->connect_error) die('Failed to connect to MySQL: '. $link->connect_error); else echo 'Connection to MySQL server successfully established.'; // check if a form has been submitted if ($_SERVER["REQUEST_METHOD"]== "POST" { $name = $POST['name']; // WHAT IF THE FORM WASN'T SUBMITTED? // SINCE YOU ARE ONLY INSERTING ONE VALUE PERHAPS YOU S/B NAMING IT IN YOUR QUERY $sql = $mysqli->prepare("INSERT INTO senior_dat VALUES (?)"); $label = 'PHP'; $sql->bind_param("is",$label); // READ THE MANUAL ON THIS SO YOU CAN USE IT CORRECTLY. OR CHANGE TO THE NON-DEPRECATED FUNCTION. // AND ADD THE SEMI. $sql->execute // HOW CAN YOU ISSUE THIS MESSAGE WHEN YOU AREN'T CHECKING IF THE EXECUTE RAN? echo "<h3> DATA saved OK"</h3>; } else echo "You have an input error";
  10. your posted connection code works for me, so it probably isn't being executed at all. what output do you get? and if it's a blank page, what does the 'view source' in your browser show? are you requesting your main page using a URL to the web server on your development system? the url should be similar to - http://localhost/your_main_file.php NOT something like file:///C:/xampp/htdocs/your_main_file.php, which is a file system path and doesn't cause the php code to be executed. your first posted code contains a number of php syntax errors that will prevent it from running at all. until you actually do item #1 on my list, php will not help you with php syntax errors in all your files because putting the php error related settings in a file won't cause the settings to take effect because the code in that file doesn't run when there's a php syntax error in that file. beyond the above points, you would need to post your current code to get any help with it. if you incorporate all the practices listed, which are designed to make your code secure, in all contexts, provide a good User eXperience (UX), by letting the user know when they did something that they can correct and prevent them from having to keep retyping information over and over, result in simple general-purpose code, that doesn't have you typing a bunch unnecessary things that don't contribute to a working application, through the php error related settings (item #1 in my list), the validation logic (item #6), and having error handling (item #9), your code will either work or it will tell you why it isn't. here's an example showing all the posted points - <?php // initialization session_start(); // why not have the connection code actually make the connection too, so that you don't need another line of code? require "conn/connect_seniorform.php"; // note: this code uses the much simpler and more modern PDO database extension // when you make the connection - // set the character set to match your database tables, so that no character conversion occurs over the connection // set the error mode to use exceptions, so that all the database statements will use exceptions (this is the default now in php8, but set it anyways) // set emulated prepared queries to false, you want to run real prepared queries // set the default fetch mode to assoc, so that you don't need to specify it in each fetch statement $post = []; // array to hold a trimmed working copy of the form data $errors = []; // array to hold user/validation errors // post method form processing if($_SERVER["REQUEST_METHOD"]==="POST") { // inputs: first_name (add others once code is working) // trim all the input data at once $post = array_map('trim',$_POST); // if any input is an array, use a recursive trim call-back function here instead of php's trim // validate all inputs // first name if($post['first_name'] === '') { $errors['first_name'] = "First Name is required"; } // validate other inputs here... // if no errors, use the input data if(empty($errors)) { $sql = "INSERT INTO senior_dat (first_name) VALUES (?)"; $stmt = $pdo->prepare($sql); // note: the following try/catch error handling deals with having a (single) unique column (email) defined in your database table // if you have multiple unique columns defined, you would execute a SELECT query inside the catch code to find which column(s) contain duplicate values matching the input data and setup an error message for each one try { // a 'local' try/catch to handle a specific error type $stmt->execute([ $post['first_name'], ]); } catch (PDOException $e) { if($e->errorInfo[1] == 1062) // duplicate key error number { $errors['email'] = "Email is already in use"; } else { throw $e; // re-throw the pdoexception if not handled by this logic } } } // if no errors, success if(empty($errors)) { $_SESSION['success_message'] = "Form saved OK"; die(header("Refresh:0")); } } // hrml document starts here... ?> <?php // display and clear any success message if(!empty($_SESSION['success_message'])) { echo "<p>{$_SESSION['success_message']}</p>"; unset($_SESSION['success_message']); } ?> <h1>SENIOR RENEWAL FORM</h1> <?php // display any errors if(!empty($errors)) { echo '<p>'; echo implode('<br>',$errors); echo '</p>'; } ?> <form method="post"> <label><b>First Name:</b><br><input type="text" name="first_name" size="20" maxlength="40" value="<?=htmlentities($post['first_name']??'',ENT_QUOTES)?>"></label> <br> <input type="submit" value="submit"> </form> if you insist on using the overly complicated and inconsistent mysqli database extension, adding the following line of code, before the point where you make the database connection, will cause it to use exceptions for errors (item #9 on my list) - mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
  11. Your last is full of errors which you are not seeing since you didn't include the error reporting code.
  12. I found on my host a connection script so I tried that and it works and gives my a message to say that it is connected. I put that a the top of my shortened script and entered my name in the name input box. I then checked the database and nothing was written. I have tried to use some prepared statements, but it did not work. As this is new to me I may have got the script wrong. Can you help? <?php $host_name = 'xxxxxx'; $database = 'xxxx'; $user_name = 'xxxx'; $password = 'xxxx'; $link = new mysqli($host_name, $user_name, $password, $database); if ($link->connect_error) { die('<p>Failed to connect to MySQL: '. $link->connect_error .'</p>'); } else { echo '<p>Connection to MySQL server successfully established.</p>'; } // check if a form has been submitted if ($_SERVER["REQUEST_METHOD"]== "POST" { $name = $POST['name']; $sql = $mysqli->prepare("INSERT INTO senior_dat VALUES (?)"); $label = 'PHP'; $sql->bind_param("is",$label); $sql->execute echo "<h3> Form saved OK"</h3>; else echo "nl2br(You have an input error)"; } ?>
  13. <?php function doThis($num = 4) { for ($i = 0; $i < $num; $i++) { $seq[] = $i; } return $seq; } $arr = doThis(); echo $arr[1]; echo $arr[2]; echo $arr[3];
  14. Return the value from the function https://www.php.net/manual/en/functions.returning-values.php
  15. Thanks for the information! I'm thinking its the connection code that isn't working! I have used the following format before and haven't had any problems. I've redacted the login data for obvious reasons. I have double checked the loin data and know that it is correct. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); //set up a connection function get_db_conn_senior() { $host_name = "xxxxxxxxxxxxxxx"; $database = "xxxxxxxxxx"; // Change your database name $username = "xxxxxxxxxx"; // Your database user id $password = "xxxxxxxxxx"; // Your password //connect to server and select database; you may need it $conn = new mysqli($host_name, $username, $password, $database); echo "Connected"; //if connection fails, stop script execution if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } return $conn; } ?> I have put the echo in to see if it connects, but no message is shown. But surely if it did not connect I would get the fail message? I cut down the html file to one input, but still not populating the database. What can I do next to get this working?
  16. how can I retrieve the single variable that I want from the function? A similar example for what I'm attempting to accomplish $seq=""; function doThis($num=4){ for($i=0; $i<$num; $i++){ echo $i."<br>"; $seq .= $i; } echo $seq; } doThis(); echo $seq; //get variable here How can I access the variable that is created inside the function, and use it on the outside?
  17. I removed the mpdf package in composer.json...Composer has been successfully updated. Now it is only with the problem with mpdf
  18. I use these packages: { "name": "laravel/laravel", "type": "project", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "require": { "php": "^7.3|^8.0", "bumbummen99/shoppingcart": "^4.2", "carlos-meneses/laravel-mpdf": "^2.1", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "hekmatinasser/verta": "^2.1", "intervention/image": "^2.7", "laravel/framework": "^8.75", "laravel/sanctum": "^2.11", "laravel/tinker": "^2.5" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.6", "facade/ignition": "^2.5", "fakerphp/faker": "^1.9.1", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^5.10", "phpunit/phpunit": "^9.5.10" }, "autoload": { "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "scripts": { "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-update-cmd": [ "@php artisan vendor:publish --tag=laravel-assets --ansi --force" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] }, "extra": { "laravel": { "dont-discover": [] } }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true } I have access to GitHub. Laravel itself has a large number of packages. Do I have to download all the desired packages individually?
  19. Below is the contents of a text file: Name: John Doe| Email: johnd@gmail.com| Staff ID: SS1234| Gender: Male| School: FECS Name: Jane Doe| Email: doejane@gmail.com| Staff ID: SS3454| Gender: Female| School: SFS Name: Scott Doe| Email: does@gmail.com| Staff ID: SS9087| Gender: Male| School: FBDA Name: Kelly Doe| Email: kellydoe@gmail.com| Staff ID: SS2093| Gender: Female| School: SFS Below is the code for the display play <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> </head> <header> <nav> <ul> <li><a href="index.php">Main Page|</a></li> <li><a href="addEmployeeForm.php">Add Staff|</a></li> <li><a href="searchEmployeeForm.php">View Staff|</a></li> <li><a href="deleteEmployee.php">Delete Staff</a></li> </ul> </nav> </header> <body> <h1>Staff Profile</h1> <fieldset> <legend>Employees Information</legend> <?php $name=""; if(isset($_POST["name"])){ $name=$_POST["name"]; } $staffID=""; if(isset($_POST["sID"])){ $staffID=$_POST["sID"]; } $email=""; if(isset($_POST["email"])){ $email=$_POST["email"]; } $gender=""; if(isset($_POST["gender"])){ $gender=$_POST["gender"]; } $faculty=""; if(isset($_POST["faculty"])){ $faculty=$_POST["faculty"]; } //$searchthis = $_POST['name']; $file = "employees.txt"; $array= file($file); for($x=0; $x<count($array); $x++){ $record[]=explode("| ",$array[$x]); } for($x=0; $x<count($record); $x++){ $search = true; if($name==""){ $search=true; }elseif(strpos($record[$x][1],$name) !==false){ $search=true; }else{ $search=false; } if($email==""){ $search=true; }elseif(strpos($record[$x][2],$email) !==false){ $search=true; }else{ $search=false; } if($staffID==""){ $search=true; }elseif(strpos($record[$x][3],$staffID) !==false){ $search=true; }else{ $search=false; } if($gender==""){ $search=true; }elseif(strpos($record[$x][4],$gender) !==false){ $search=true; }else{ $search=false; } if($faculty==""){ $search=true; }elseif(strpos($record[$x][5],$faculty) !==false){ $search=true; }else{ $search=false; } if($search==true){ echo $record[$x][0],"<br>" .$record[$x][1],"<br>" .$record[$x][2],"<br>" .$record[$x][3],"<br>" .$record[$x][4],"<br>"; } } ?> </fieldset> </body> </html> Here is code for the form <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> </head> <header> <nav> <ul> <li><a href="index.php">Main Page|</a></li> <li><a href="addEmployeeForm.php">Add Staff|</a></li> <li><a href="searchEmployeeForm.php">View Staff|</a></li> <li><a href="deleteEmployee.php">Delete Staff</a></li> </ul> </nav> </header> <body> <h1>Staff Information</h1> <hr> <form action="displayEmployeeinfo.php" method="post"> <p>Staff Name:</p> <input type="text" id="name" name="name"> <p><input type="submit" name="confirm" value="Search"></p> </form> </body> </html> The basics are working but I want it to show a specific name that will display the info related to the searched name.
  20. It's a path type repository. You can also set up a github repository as a composer source, which may actually be what the OP is discussing.
  21. Composer needs to do other work besides just download from GitHub. If you can download it yourself manually then you should be able to put it on your computer somewhere and tell Composer to read from it instead of GitHub. I forget the exact method but I believe you put a custom "repository" in your composer.json.
  22. Yesterday
  23. i think there is kind of a bug with gmail where when using a ipad it can sometimes appear sessions on a mac or mobile due to something related to the fact that ipads are using a computer setup like deskop but i am definitely being target by hacker as soon as my security settings have a problem there is someone getting in my gmails by recovering the accounts i dont think there is much i can do to avoid being targeted...
  24. Yes, I tried several times. Is there another way to update the package without using the terminal? Due to the spread of protests in Iran, the internet is severely limited and filtered, and I have to use a VPN. If you have a solution, please tell. Thanks
  25. Which binaries do you expect? The ones for Apache support? The FPM daemon? FastCGI? Just the CLI? Debian/Ubuntu separate PHP into multiple subpackages. "php5.6" is a metapackage with only a handful of files itself. You typically install the more specific packages in addition/instead. nginx and php-fpm are separate. You install and configure both individually. Apache and mod_php are not separate because that approach has PHP as an Apache module so they're directly related. It's the traditional configuration, and one that's mostly fallen out of favor.
  26. The joys of migrating… which explains why no one wants to do it and we end up with totally outdated and unsecure old servers. 5.6 should be fine to try migrating. A couple more questions: 1. Why does the php5.6 package contain no binaries? ~# apt-get download php5.6 ~# dpkg -c php5.6_5.6.40-63+0~20220929.69+debian11~1.gbp639d4c_all.deb drwxr-xr-x root/root 0 2022-09-30 00:13 ./usr/ drwxr-xr-x root/root 0 2022-09-30 00:13 ./usr/share/ drwxr-xr-x root/root 0 2022-09-30 00:13 ./usr/share/bug/ drwxr-xr-x root/root 0 2022-09-30 00:13 ./usr/share/bug/php5.6/ -rw-r--r-- root/root 25 2022-09-30 00:13 ./usr/share/bug/php5.6/control drwxr-xr-x root/root 0 2022-09-30 00:13 ./usr/share/doc/ drwxr-xr-x root/root 0 2022-09-30 00:13 ./usr/share/doc/php5.6/ -rw-r--r-- root/root 480 2022-09-18 14:52 ./usr/share/doc/php5.6/NEWS.Debian.gz -rw-r--r-- root/root 82584 2022-09-30 00:13 ./usr/share/doc/php5.6/changelog.Debian.gz -rw-r--r-- root/root 178252 2022-09-30 00:13 ./usr/share/doc/php5.6/changelog.gz -rw-r--r-- root/root 21026 2022-09-18 14:52 ./usr/share/doc/php5.6/copyright 2. To install php on nginx… how to prevent it from installing Apache as well? Is installing php-fpm enough to run PHP on nginx? ~# apt-get install --download-only php5.6 Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5.6 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.3-0 libpcre3 php-common php5.6-cli php5.6-common php5.6-json php5.6-opcache php5.6-readline ssl-cert Suggested packages: apache2-doc apache2-suexec-pristine | apache2-suexec-custom The following NEW packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5.6 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.3-0 php5.6 php5.6-cli php5.6-common php5.6-json php5.6-opcache php5.6-readline ssl-cert The following packages will be upgraded: libpcre3 php-common 2 upgraded, 17 newly installed, 0 to remove and 32 not upgraded. Need to get 0 B/6,465 kB of archives. After this operation, 22.5 MB of additional disk space will be used.
  1. Load more activity
  • 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.