Jump to content

tunnelboy

Members
  • Posts

    15
  • Joined

  • Last visited

Everything posted by tunnelboy

  1. Database column SKU is set up as varchar(30) Sample SKU items in DB: MG1334 866jj6 34249 0MFG88367 00A MUJY082JLKKSOY $sql = "SELECT sku from marketplace"; $resultdID=$db->query($sql)->fetchAll(); foreach($resultdID as $row) { echo $row['sku']."<br>"; } Results: MG1334 866jj6 34249 MFG88367 A MUJY082JLKKSOY What's going on and how to prevent it? When I browse my data with PhpMyAdmin, I have other tables in my system with similar data and I never experienced anything like this. Google Search results say to set my column as VARCHAR but it was always that from day one. Thanks
  2. Ok, I get it. How would the DB know there are 5 options? That makes total sense. To simplify things, I used Amazon's rating thing. In reality, this is a quiz composed of 15 questions each of varying lengths. Like the first question has 5 options, the 2nd has 4, etc. All I have to do is pass the number of expected results. Sometimes things are SO simple, they blind you! Thanks very much both of you!
  3. I can't wrap my head around this one. If you look at the reviews of an item on Amazon, they show a little graph with something like: 5 stars - 107 4 stars - 23 3 stars -3 2 stars - 0 1 star - 3 I have a simple table along those lines. key rating 1 3 2 5 3 5 4 5 5 2 6 2 7 5 I want to count how many of each, so I do: SELECT rating,sum(*) FROM reviews GROUP by rating and I'll get something like this: 1 - 2 2 - 1 3 - 1 5 - 4 But I need to get that zero (0) from the 4 star rating (that nobody selected). I want: 1 - 2 2 - 1 3 - 1 4 - 0 5 - 4 Thanks
  4. Thank you so much for that info! I'm 64 and this all used to come a LOT easier to me. Now my mind is getting muddy with the way things have changed (specifically shorthand or shortcuts and objects). But I refuse to give in and want to keep exercising my brain.
  5. Ok, I'm trying to convert from another payment processor to stripe. The call to Stripe goes like this and this demo works: $session = \Stripe\Checkout\Session::create([ "success_url" => "https://www.domain.com/stripesuccess.php?sid={CHECKOUT_SESSION_ID}", "cancel_url" => "https://www.domain.com/cart.php", "mode" => 'payment', "line_items" => [ [ "price_data" =>[ "currency" =>"usd", "product_data" =>[ "name"=> "WIDGETB", "description" => "Blue Widget" ], "unit_amount" => 5000 ], "quantity" => 1 ], [ "price_data" =>[ "currency" =>"usd", "product_data" =>[ "name"=> "WIDGETG", "description" => "Green Widget" ], "unit_amount" => 2000 ], "quantity" => 2 ] ]); The problem is I'm pulling the line items from a DB. How to format these line items in a loop and format it properly? (Newbie here... not even clear whether the above is an object or array or what), but I know I can't just throw a loop in the middle to add my dynamic line items. // Pulling shopping cart from a DB into $row array. Holds cart info. price, qty,sku and description / Mysql fetchAll here foreach ($resultID as $row) { $line_items_array = array( "price" => $row['price'], "quantity" => $row['qty'], "sku" => $row['sku'], "description" = $row['description'] ); } How do I put this array of multiple items into the Stripe code and preserve the formatting in the first example? I know this is a very vague question, but hoping someone will understand what I'm trying to do. Thanks
  6. SELECT * FROM database WHERE col1 LIKE '%foo%'; Simple. But I've got to do this backwards. In my col1 database, I have values like this: pk col1 1 Joe 2 Susan 3 Richard|Joe 4 Jane|Sam|Steve 5 Gloria|Joseph My search criteria is coming from another database of SINGLE NAMES, so I want to do this: SELECT * FROM database WHERE '%col1%' LIKE 'Joe'; And I want to return keys 1,3 & 5. I've tried the above, I've tried '%'+col1+'%'. Neither work. Thanks
  7. I agree with you 100% I have been using Stablehost for a very long time and it *was* great. Then they sourced their support overseas and it's been horrible ever since. Whatever the issue, it's NEVER their fault. Never ever. I had my MySQL locked up like a week ago, and I was actually pleading with them to restart the server and they insisted everything was fine. He finally agreed to restart it and all was fine seconds after restarting it. I have already gone with another host. I'm dreading the move, but just wanted to make sure there wasn't an issue that I was doing. Thank!
  8. Built an ecommerce site from scratch 10+ years ago. Haven't changed anything significant. Now all of the sudden, some users are reporting lost sessions (empty carts, or empty carts upon return from a PayPal transaction, etc). I've put in a simple check that writes the results to a log page, and there is no understanding what is wrong. # Example page 1 session_start(); $_session['foo'] = "test"; # Go to page 2 #Example page 2 session_start(); if ($_session['foo'] != "test") exit("Session Lost!"); Often it works, sometimes it doesn't. Of course the script is more involved, but the check for a lost session is RIGHT AFTER session_start(); And I have it set to a log file, so I can see if and when it happens. Odd thing is that it's working most of the time. I get orders. But some people have said their cart is emptying. My host said everything is working fine on their end. Any ideas? Where to start? How to troubleshoot further? Should I just append a custom $sid to every URL with like a hidden form entry? Very frustrating.
  9. Trying to create a very simple API script sending XML data. When I send the "hard coded" XML, it works perfectly. When I add a form to supply the data for the XML, I get a 500 Internal Server error. Have tried it on two different servers. No error in the logs. Stumped. Examples below are VERY simplified (and obviously won't do anything as-is) to show what I'm dealing with. This one works fine: <?php $xml = "<Order><UserId>foo</UserId><Password>foo</Password><Mode>Test</Mode><Name>Charles R. Hodges</Name>"; $xml .= "</Order>"; $url = 'http://sitename.com'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($response); print_r($xml); ?> And then I use this one and all heck breaks loose with the 500 Internal Error: <?php if (isset($_POST['submit'])) { $xml = "<Order><UserId>foo</UserId><Password>foo</Password><Mode>Test</Mode><Name>{$_POST['name']}</Name>"; $xml .= "</Order>"; $url = 'http://sitename.com'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($response); print_r($xml); exit; } ?> <html>... etc <form method="post" action=""> Name: <input type="text" name="name" /> <p><input type="submit" name="submit" "Add to XML string and send" /> </form> ?>
×
×
  • 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.