0

I found a tshirt designer on github and have been working on it. I managed to get the customer function to insert into the database but it does not post the order details into the database. I get this error :

Notice: Undefined variable: selectNumRows in G:\xampp\htdocs\tdesigner\php\send.php on line 73

Though when I check the code on line 73 and forth, I don't see any problems to it.

The function code:

/* Get the number of rows and current customer information */
if ($selectCurrentCustomer = $mysqli->prepare($querySelect)) {
    /* Fetch the SELECT data */
    $selectCurrentCustomer->execute();
    $selectCurrentCustomer->bind_result($id);
    $selectCurrentCustomer->store_result();
    $selectCurrentCustomer->fetch();
    /* Store the customer ID and number of rows found */
    $selectNumRows = $selectCurrentCustomer->num_rows;
    $customerId = (selectNumRows == 0) ? $id : null;
    /* Close the query */
    $selectCurrentCustomer->close();
}

/* If not a returning customer, insert them into the database. Otherwise, update the existing customer */
if ($selectNumRows == 0) { //  LINE #73

I hope someone could help me on this. Thank you.

Phil
  • 157,677
  • 23
  • 242
  • 245
Vaulient
  • 335
  • 1
  • 4
  • 14
  • 3
    You're missing $ to the variable in the ternary check. – Paul T. Feb 26 '19 at 04:18
  • @PaulT. that should result in a different error though ~ _"Warning: Use of undefined constant selectNumRows - assumed 'selectNumRows'"_ – Phil Feb 26 '19 at 04:21
  • Which line is #73? Also make sure you've exactly copy / pasted your code into your question – Phil Feb 26 '19 at 04:22
  • @Phil: ...that's likely correct, however, I have no idea what line 73 is in the posted code? ... the first thing that jumped out at me. – Paul T. Feb 26 '19 at 04:23
  • 1
    Is it [this file](https://github.com/StevenFrost/Apparel/blob/master/php/send.php#L73)? If so, you should set PDO to throw exceptions. My guess is the `prepare()` call is failing (silently), therefore `$selectNumRows` is never set and the **actual code** on line #73 is outside that `if` block – Phil Feb 26 '19 at 04:26
  • Also, as pointed out by @PaulT., you are missing a `$` before `selectNumRows`. If that isn't your Github project, I'd start filing some bugs – Phil Feb 26 '19 at 04:31
  • Thank you for the reply guys!! I appreciate it. Got it sorted out :) – Vaulient Feb 28 '19 at 13:12

0 Answers0