Jump to content

nodirtyrockstar

Members
  • Posts

    108
  • Joined

  • Last visited

Everything posted by nodirtyrockstar

  1. Just in case you still need further clarification, Ch0cu3r is right that you don't need both. You can write HTML to the screen with PHP, most commonly like so: echo "<h1>HTML</h1>";
  2. It looks like your link is wrong. You said your directory for the second file is here: /htdocs/tables/php/projects.php, but you're including a file at php/projects.php. You need to send it to the tables directory first, then into the php directory, and finally to your document. Oh, my bad...I looked more closely at it. I think your link is right. Sorry.
  3. I think you are making a lot of assumptions about what classes I have and what they are doing. My input class only does one thing. It handles input. The way I handle the user's order is not something I really went into on here, but suffice it to say, it is separate from the Input class.
  4. I agree with previous commenters that it would help to know what your link does when you click on it. PLEASE don't use JavaScript. That is a hack. Try putting the type="submit" attribute on the input. The name attribute gives the element a name, and the value is the actual data you are passing. You should consider reading the API. MDN is better than w3schools.com. They're notoriously wrong. Here ya go: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input If this works, please don't forget to mark my answer as the solution. (please)
  5. The image should not affect your ability to submit. It is just a cosmetic feature. Looking into it now. Found a red herring and edited this post.
  6. Alright, thanks for reading. I am going with putting it into the Input class.
  7. Requested quantity can't be the key in an array, because it isn't necessarily unique.
  8. I'm writing some classes right now for a website with a shopping cart. There are all kinds of classes, Blog, Cart, Product, Database, etc. I am trying to make a design choice about where to store the requested quantity for a particular product. I feel like it should NOT go into the Product class, because the requested quantity does not semantically relate to any of the standard product detail. I was considering maybe setting the quantity property of the product instance, to the requested quantity, once it is put into the cart. For some reason my instinct says no, that it should be abstracted out, perhaps into the Cart class. If that is the case, how do you couple the requested quantity with the requested object? As array key/value pair? Is there another class it could go into? Does anyone have practical experience to shed some light on this?
  9. Okay, I found that using the var keyword automatically declares it as public. Does that mean it is still possible to modify privacy with private or protected here?
  10. Is it considered incorrect practice to declare privacy modifiers on variable/properties of subclasses? for example: class SubClass { var $property = 'notice there is no private, public, or protected keyword here'; }
  11. Basically what I can see is that I am failing to create the apiContext object. Can anyone see where the error is? Please tell me how I can improve the question. Here is the error: Fatal error: Uncaught exception 'PayPal\Exception\PPConnectionException' with message 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.' in /vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php:104 Stack trace: #0 /vendor/paypal/sdk-core-php/lib/PayPal/Transport/PPRestCall.php(44): PayPal\Core\PPHttpConnection->execute('{"intent":"sale...') #1 /vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php(246): PayPal\Transport\PPRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{"intent":"sale...') #2 /pymt.php(38): PayPal\Api\Payment->create(Object(PayPal\Rest\ApiContext)) #3 {main} thrown in /vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php on line 104 This is the PHP sample I'm using. I am trying to run it off my server. If a customer clicks the pay with paypal button, it runs the following sample script: <?php require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Address; use PayPal\Api\Amount; use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; use PayPal\Api\RedirectUrls; use PayPal\Api\Transaction; session_start(); $payer = new Payer(); $payer->setPayment_method('paypal'); $amount = new Amount(); $amount->setCurrency('USD'); $amount->setTotal('1.00'); $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setDescription('This is the payment description.'); $baseUrl = getBaseUrl(); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturn_url('baseUrl/sale.php'); $redirectUrls->setCancel_url('baseUrl/saleFail.php'); $payment = new Payment(); $payment->setIntent('sale'); $payment->setPayer($payer); $payment->setRedirect_urls($redirectUrls); $payment->setTransactions(array($transaction)); try { $payment->create($apiContext); } catch (\PPConnectionException $ex) { echo 'Exception: ' . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } foreach ($payment->getLinks() as $link) { if ($link->getRel() == 'approval_url') { $redirectUrl = $link->getHref(); } } $_SESSION['paymentId'] = $payment->getId(); if(isset($redirectUrl)) { header('Location: $redirectUrl'); exit; } ?> Here's the redacted bootstrap.php: <?php /* * Sample bootstrap file. */ // Include the composer autoloader if(!file_exists(__DIR__ .'/vendor/autoload.php')) { echo "The 'vendor' folder is missing. You must run 'composer update --no-dev' to resolve application dependencies.\nPlease see the README for more information.\n"; exit(1); } require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/common.php'; use PayPal\Rest\ApiContext; use PayPal\Auth\OAuthTokenCredential; $apiContext = getApiContext(); /** Helper method for getting an APIContext for all calls * * @return PayPal\Rest\ApiContext */ function getApiContext() { // ### Api context // Use an ApiContext object to authenticate // API calls. The clientId and clientSecret for the // OAuthTokenCredential class can be retrieved from // developer.paypal.com $apiContext = new ApiContext( new OAuthTokenCredential( 'MY CLIENT ID', 'MY SECRET' ) ); // Register the sdk_config.ini file in current directory // as the configuration source. if(!defined("PP_CONFIG_PATH")) { define("PP_CONFIG_PATH", __DIR__); } return $apiContext; } ?> Can anyone help? Let me know if you need more info. Thanks up front.
  12. I am sure you're right. I'll see if I can get this working. Can anyone answer this for me: what is the issue with fetch_all()?
  13. I'm using PHP 5.3.13. I am just using a very simple query to grab one column of results from a table. I would like to fetch them and then iteratively add them to a dropdown menu. I am trying to understand these methods/functions and seem to be missing something. My research on Google didn't give me any indication of what I'm doing wrong. I start with one of the simplest queries possible, which I know will return a data set as I have tested it in mysqladmin. The problem arises when I try to call the method on the mysqli_result object. $query = "SELECT `artist` FROM `bands`;"; $result = $mysqli->query($query); $bandArr = $result->fetch_all(); The error I'm getting from the above code is: Fatal error: "Call to undefined method mysqli_result::fetch_all()..." I researched this error and read somewhere that you need mysqlnd. Is that true? Do I need to look into my PHP configuration to get this to work? Is it worth it for this task? Then I tried fetch_array... $query = "SELECT `artist` FROM `bands`;"; $result = $mysqli->query($query); $bandArr = $result->fetch_array(MYSQLI_NUM); printf("%s\n%s", $bandArr[0], $bandArr[1]); And the above code for some reason returns an array with only one item, and this error: "Notice: Undefined offset: 1 in..." What am I missing here? Again, all I want is a small result set from one column which can be iterated and each value added to a drop down menu. Thoughts? Suggestions? Thanks in advance for any help you can offer...
  14. I guess my question was too vague! Sorry. I am using PHP and mysqli. I am used to writing prepared statements to deal with user input/repetition. Since I just need to auto-pop a drop down menu with a list of items found in one column of my table, I was hoping to use the simpler $mysqli->query() method, and just wanted to check in with the experts first.
  15. I would like to run a simple query one time without user input. Can I just use a query? Or is there benefit to doing it another way?
  16. I'm going to think about this, work on trying to understand Ignace's post, and I'll post again probably tomorrow. Thanks for the input!
  17. Unfortunately, I do not have a degree in database administration, so I'm going to need some help understanding that last post.
  18. Thanks for answering, Barand. These answers seem on par with my expectations. I have some follow up questions. 1. I hear what you are saying. I need a little more help, though. Let's use the band member table as an example. I have one band with a relationship to many members, and there are many bands with this same relationship that all need to be stored. Do I have to make a table for each new band? That doesn't seem wise. So what is the unique key that I use in the band table to reference all the members of a particular band in the member table? On a previous project I created a composite key, so I'm thinking that is the solution. However, I am struggling to figure out what other field I should combine in order to connect the band in the bands table to the members in the member table, since the band will be repeated in the members table. Does that make sense? (FYI I am using MyISAM, because my host does not offer InnoDB.) 2. I read online that fields containing large amounts of text can slow down queries. Would you agree with that? If so, do you recommend putting that into a separate table? 3. Noted. I will create two separate date fields. 4. I realized that I failed to mention that (of course) I will want to reference the records that each band has recorded, since the primary goal of this website is to sell records. Aside from each record entry containing a reference to the band, would you recommend any additional references between the band and the records?
  19. Right now I'm working on a website for a record label. I need to write a script that switches between bands and pops band info based on user selection. If it was just PHP, the fields would be: string (band photo; url src to an img), an array of strings (streaming music; multiple url src to mp3 links), string (duration; this one is actually two dates that represent a span of time), array of strings (players; key & value pairs that represent band members and what they do in the band, i.e. drummer, bassist, etc.), string (band bio; it will need to be a couple paragraphs). Since I need to store this information in a database, I am first planning the structure for the table(s) that I will need to create for this. For now, I have three areas of concern. 1. Regarding the arrays, if the absolute max number of key/value pairs is ten, is it okay to store those in a single field? Or should I create another table and make a compound key to reference the main band table? 2. I plan to use either blob or text field for band bio. Any tips you would like to offer about those two data types would be helpful, though I will be doing plenty of reading about them regardless. 3. As for duration, can anyone think of any reason I should actually break that into two date fields? I don't think there will ever be a reason to run any calculations on how long they have been together, so I am thinking a string will be fine. If you disagree with that assessment, I wouldn't object to hearing your reasoning. Any input you can offer would be greatly appreciated!
  20. I found the same answer at this link, Jessica. It basically says that you need to plug the table name in using a variable, which means you'll have to sanitize/validate it first. Thanks for your time everyone!
  21. Actually, I have another question related to this. At runtime, my script actually has the table value stored in a PHP variable. Is it possible to use bind_params when preparing the query to plug in the table name? $stmt = $mysqli->prepare("SELECT * FROM ? WHERE `id` = ?;"); $stmt->bind_param('ss', $tbl, $id); I tried the code above and it isn't working.
×
×
  • 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.