Jump to content

webdeveloper123

Members
  • Posts

    437
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by webdeveloper123

  1. Do you have a backup of your website? @maxxd - if she does can she safely simple copy & paste cron.php back into that folder?
  2. If you found it, you should use the code I posted and put it near the top or at the top. Eg <?php include 'includes/cron.php' ?> <?php require 'includes/cron.php' ?> But you have to make sure the cron.php is in a folder called includes. If you have a different folder name, you should use that instead. It might be a good idea to screen shot the folder where cron.php is in and share some more code. E.g - the original include and require lines of code
  3. did you look inside for cron.php? Is it an actual file that exists in the folder?
  4. Have you looked in those folders for the cron.php file? Seems like your using wordpress, which may mean you could update out of date plugins, but I wouldn't recommend messing with the php files that come with that plugin/wordpress unless you know what your doing btw if you want to include or require a php file the code is: <?php include 'includes/header.php' ?> or <?php require 'includes/header.php' ?> both above are stand alone, but you can remove opening and closing php tags to fit it into your script The part after the first "include" and the first "require" is the location of that file.
  5. I would suggest you get a book called Php&MySql by Jon Duckett - most of the tasks you mentioned are readily available in the book. Hint: if you made an attempt to write the code and had problems and then posted those problems on here, you would get more replies and more help. If you want someone to code your assignment for you , go to fiverr.com and hire someone
  6. Thanks I didn't know that. I'm thinking of backing up everything and then getting XAMPP, because then If I install AMPPS, I'm back to square one if I want to upgrade php again
  7. btw, I tried updating to php 8 via ampps and It can't be done with the version I'm running. Trust me, I've been at it for 2 days. It will say on the website you can and show tutorials, but when I follow the tutorials links are missing, things don't come up as expected and I can only downgrade my php, not upgrade. I think it is because I am running the free version.
  8. Hi Guys, I wanted to upgrade to php 8.1, locally. I found a tutorial online that show's how to do this and I understood the steps. The thing is It is asking me to change environment variables, which is fine because I've done it before for another programming language so I am familiar with it. I should say at this point I am using AMPPS on Windows 10. Thing is he says in the tutorial "If you don't already have php" under Enviroment variables ->System Variables -> [Path] -> Edit then add it. I don't see anything with php there but I do have php 7.3 running locally. And another thing I was concerned about he just went to DOS after installing it and used the command -> php -version and he's came up at the correct version that he installed. I did this before I have done anything from the tutorial and it comes up with php not recognised. And while he was sharing he's screen for the tutorial I saw he had a "xampp" folder and I am running "ampps" So I guess that question is, is it safe to follow that tutorial. Because the only other option is to delete AMPPS and download the latest version. Here is the link: https://www.youtube.com/watch?v=ITweSppjLlY. I will break that tutorial down: First he downloads the php version he is installing. Unzips etc Placed the folder in the c:/ drive Goes to System properties -> Environment variables Under System Variables -> Path and then edit Then he says If you have php there, delete it Then add new, and add the path of the unzipped folder from the c:/ drive Then Ok every screen Thanks
  9. haha yes Barand! It's working. Honestly, I'm not even joking I was coming downstairs today thinking I am going to use $invoiceOutput in the condition for the do...while loop! With regards to the code you wrote. I Know you went out of your way to do that & I appreciate it it's just that I was just trying to extract the php because I had something particular in mind for the css. And echoing large parts of HTML in variables etc I'm not too familiar with so I wanted to do it my way Thank you!
  10. I got the output of what was inside the loop. I just didn't show it. It's just not in the loop, I am printing the variables outside the loop. I am doing the php first then I am going to do the HTML and CSS later. echo ("The customer id is $FormId</br>"); echo ("$cusName</br>"); echo ("$orderDate</br>"); echo ("$address</br>"); echo ("$town</br>"); echo ("$county</br>"); echo ("$postCode</br>"); echo ("$amount</br>"); echo ("$inv_total</br>"); productname, qty and amount are just that, it prints the product name, qty of how much they bought and the amount for that row (eg. Blu Ray Player, 7, £150 for example (£150 is the total for 7 Blu Ray Players)
  11. Hey guys, I am pretty close but there is a few things I don't understand why it's not working. The manual says: Fetches one row of data from the result set and returns it as an associative array. Each subsequent call to this function will return the next row within the result set. So I make a subsequent call to the function according to Barand pseudo code (which is higher up the thread) . This is my code: $invoiceOutput = mysqli_query($link, $invoice); $inv_total = 0; $row = $invoiceOutput->fetch_assoc(); $cusName = $row['customername']; $amount = $row['amount']; $orderDate = $row['order_date']; $address = $row['address']; $town = $row['town']; $county = $row['county']; $postCode = $row['post_code']; do { $pName = $row['productname']; $qty = $row['qty']; $amount = $row['amount']; $inv_total += $row['amount']; } while ($row = $invoiceOutput->fetch_assoc()); <td><?php echo $pName; ?></td> <td><?php echo $qty; ?></td> <td><?php echo $amount; ?></td> If Each subsequent call to the function returns the next row, why am I only getting one row printed out within my td elements. Or is it that there is only one record there in the first place? Because in the pseudo code he says to: Read first row So i'm a bit confused. Can you help please? Btw, I also tried these 2 as well: $row = mysqli_fetch_assoc($invoiceOutput) $row = $invoiceOutput->fetch_array(MYSQLI_ASSOC);
  12. I was actually on that page this morning reading through it, I'll give it a good read
  13. So I should have a do...while and a while loop in there at the same time?
  14. @ginerjm it looks like I have to switch the do...while loop with your while loop. Is that right? Because If I do, how am I supposed to get the invoice total which was the reason to switch the loops in the first place?
  15. I didn't know that it only fetched one row. I just used the code you gave me. I've only been doing php for 5 months and your do...while loop was the first proper time I used it (outside of trivial examples like print numbers 1 to 10)
  16. Hi Guys, I know this is pretty basic stuff and I have done it loads of times successfully (using different code structure) but I've been at it since yesterday and just can't figure it out. All my code was fine but then I had to switch from a while loop that fetches the sql query and saves each row to a array, then I loop over that array in a foreach and print out my results. Now the sql query is saved in $row, so I am trying to use $row in my foreach but it's not printing the values. Surely if my resultset is stored in $row I should be able to use foreach on it. I think my echo statements might be wrong, but I've tried multiple ways. Here is my code: $invoice="SELECT order_details.order_id, DATE_FORMAT(orders.order_date, '%M %e %Y') as order_date, concat(customer.first_name, ' ', customer.last_name) as customername, customer.address, customer.town, customer.county, customer.post_code, product.name as productname, order_details.qty, order_details.qty * product.price as amount FROM order_details JOIN orders ON orders.order_id = order_details.order_id JOIN customer on customer.customer_id = orders.customer_id JOIN product ON order_details.product_id = product.product_id WHERE order_details.order_id = '$last_id'"; $invoiceOutput = $link->query($invoice); $inv_total = 0; $row= $invoiceOutput->fetch_assoc(); print_r($row); do { $cusName = $row['customername']; $amount = $row['amount']; $orderDate = $row['order_date']; $address = $row['address']; $town = $row['town']; $county = $row['county']; $postCode = $row['post_code']; $inv_total += $row['amount']; } while ($row = $invoiceOutput->fetch_assoc()); if ($row) { foreach ($row as $d_row) { ?> <tr> <td><?php echo($d_row["productname"]); ?></td> <td><?php echo($d_row["qty"]); ?></td> <td><?php echo($d_row["amount"]); ?></td> </tr> <?php } } my print_r($row) shows this, which can't be right because it only shows 1 Product, when that person has actually purchased 3 products: Array ( [order_id] => 117 [order_date] => May 30 2022 [customername] => Harry Maguire [address] => 109 Temple Gardens [town] => Brixton [county] => Lambeth [post_code] => B8J 3QD [productname] => 4 Pin Microphone [qty] => 4 [amount] => 195.96 ) And for the echos I also tried: <?php echo $d_row["productname"]; ?> <?php echo $d_row["qty"]; ?> <?php echo $d_row["amount"]; ?> Could someone please help?
  17. Hey barand, I ended up using your output variable, looks great. Thanks for all your help. 👊
  18. yes. Can you help me out with that foreach. Surely if the resultset is saved in $row, then I should be able to use $row in my foreach?
  19. yeah I know they do different things, but I meant I thought I could use them both in the same code I had
  20. Wait now my other loop is broken as well. Before when I was using the table array I just used a foreach to loop over table and print the results. But I have since amended it to this: if ($row) { foreach ($row as $d_row) { ?> <tr> <td><?php echo($d_row["productname"]); ?></td> <td><?php echo($d_row["qty"]); ?></td> <td><?php echo($d_row["amount"]); ?></td> </tr> <?php } } ?> It's not printing any values. Can you help please?
  21. actually I think I did it, all I had to do was put it in the loop
  22. Hello, I know this is a basic question and I know you have shown how to print values from the query in your $output variable but I'm used to using the: $table = []; while ( $row = mysqli_fetch_assoc( $invoiceOutput ) ) { $table[] = $row; } $name = $table[0]["customername"]; and I wanted to know what the equivalent was using your do...while loop. I am trying this: <?php $cusName = $row['customername']; echo ("This is name $cusName"); print_r($row); ?> But I get: Trying to access array offset on value of type null in On line: $cusName = $row['customername']; And the print_r shows nothing at all. I also tried variations of: {$row['customername']} Trying to store the above in a variable, removing the {}, putting a ; at the end etc Because what happened was when I used your do...while loop it broke my table array and had a knock on effect on all my storing the values like this: $name = $table[0]["customername"]; And I was echoing those values Thanks
×
×
  • 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.