Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by webdeveloper123

  1. Who's work did I copy as my own? I marked as your solution, I never claimed I wrote that code. That's how a forum works. You get stuck, ask a a question and sometimes you get the correct answer.
  2. I will, it's just the learning process. everyone learns at their own pace, and some people get stuck in bad habits
  3. <?php $files = glob("images/*.{jpg,png,gif,svg,jpeg,bmp,webp}", GLOB_BRACE); $cnt = count($files); $i = 0; ?> <div class="slideshow-container"> <?php foreach ($files as $filename) { $i++; echo " <div class='mySlides fade'> <div class='numbertext'>$i / $cnt</div> <img src='$filename' style='width:20%;'> </div> "; } ?>
  4. haha clever guy. Thanks, and thanks for the numbertext, I wasn't sure how to do that one!
  5. thanks ginerjm i'll give that a go Sorry mac_gyver I don't know what your getting at. I read about the format specifier on php.net are you saying the %s is clashing with width:100%?
  6. Hi Guys, I am creating an image gallery. I already have working code to select and upload a image into a directory. I have successfully used glob and a foreach loop to display the images from that folder on to a page. I found some code on "W3C How to" which had ready made image gallery with css and JS included. Here is the link: https://www.w3schools.com/howto/howto_js_slideshow.asp What I am trying to do is echo the html in a foreach loop. I am doing ok so far but I can't get an html attribute into my echo code. Here is what I am trying to echo: <div class="mySlides fade"> <div class="numbertext">1 / 3</div> <img src="img1.jpg" style="width:100%"> </div> Here is what I have: $files = glob("images/*.{jpg,png,gif,svg,jpeg,bmp,webp}", GLOB_BRACE); foreach ($files as $filename) { echo '<div class="mySlides fade">'; echo '<div class="numbertext">1 / 3</div>'; printf("<img src='images/%s'/>" , basename($filename)); } The above code does display all images from the folder "images" onto the page so that's fine. Now the printf replaces the <img src="img1.jpg" style="width:100%">; But I can't seem to get the style="width:100%" Into the printf statement. I have been trying for hours, escaping characters, going in and out php etc etc but Can't figure it out Can someone help please?
  7. just get some code on the page, even if it's basic and just build from there
  8. Hi guys, I've got this error: Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in /var/www/vhosts//customer/edit.php:138 Stack trace: #0 /var/www/vhosts/customer/edit.php(138): PDOStatement->execute(Array) #1 {main} thrown in /var/www/vhosts/customer/edit.php on line 138 Now I researched it and apparently its because my $customers array has 11 keys and my update statement has 10 attributes (excluding the WHERE clause) which is the customer ID record I am trying to update. Apparently if they don't match up, there will be an error. Here is my $customers array and my GET statement for the customer id $id = $_GET['user_id'] ?? ''; $customers['customer_id'] = $id; $customers['first_name'] = $_POST['fname']; $customers['last_name'] = $_POST['lname']; $customers['address'] = $_POST['address']; $customers['town'] = $_POST['town']; $customers['county'] = $_POST['county']; $customers['post_code'] = $_POST['postcode']; $customers['birthdate'] = $_POST['birthday']; $customers['email'] = $email = $_POST['email']; $customers['terms'] = (isset($_POST['terms']) and $_POST['terms'] == true) ? true : false; $customers['fav_food'] = $_POST['fav_food'] ?? ''; $valid = in_array($customers['fav_food'] , $food_choice); $errors['fav_food'] = $valid ? '' : 'Must enter a food type'; And here is my sql/pdo: $sql = "UPDATE customer_details SET first_name = :first_name, last_name = :last_name, address = :address, town = :town, county = :county, post_code = :post_code, fav_food = :fav_food, birthdate = :birthdate, email = :email, terms = :terms WHERE customer_id = :id;"; $statement = $pdo->prepare($sql); $statement->execute($customers); This is the line I get the error on: $statement->execute($customers); Many thanks
  9. I thought something was up with the hyphens and slashes but I wasn't sure. I left it as slashes because that's what it had on the locale setting on the form. It's showing up as Date is valid. Thanks so much Barand
  10. Yes that's what you said to put it on, Y-m-d. And then there is the locale setting when using the html date element, which in the forms shows UK date format - d-m-Y
  11. $_POST['birthdate'] holds the value:[birthday] => 1991-02-27 and $customers['birthdate'] holds the value: [birthdate] => 1991-02-27
  12. sorry barand missed that part this is my function: function check_date($input, $format='Y/m/d') { $date = DateTime::createFromFormat($format, $input); return ($date && $date->format($format) === $input); } and the input value was: 27/02/1991
  13. Ok So I have this code: if (!check_date($customers['birthdate']) ) { $errors['birthdate'] = 'Invalid date'; } else { $errors['birthdate'] = ''; } Which is giving me "Invalid Date" in my errors array And the test code you gave me higher up the thread which is: echo check_date($_POST['birthdate']) ? 'Date is valid' : 'Date is NOT valid'; I get "Date is NOT valid"
  14. sorry I must have not made it clear I changed it to Y-m-d
  15. oh yes my mistake. I corrected it and it still says "Invalid date" in my errors array and it still says : Date is NOT valid
  16. I get a very neat looking array output and in that there is: [birthday] => 1991-02-27 Then I get: Notice: Undefined index: birthdate in /var/www/vhosts on the echo check_date line and then I get: Date is NOT valid
  17. lol Yes I said I changed it to 'd/m/Y' and the error had gone (on screen error) then I was asking should it be 'd/m/Y' or 'Y/m/d' and from your reply you said Y/m/d so I changed it to Y/m/d
  18. Hey barand I ran your code and got this error: Fatal error: Uncaught TypeError: print_r() expects parameter 2 to be bool, int given in /var/www/vhosts/ btw, my function format is 'Y/m/d'
  • 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.