Jump to content

Phi11W

Members
  • Posts

    163
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by Phi11W

  1. Classic "Buffering" problem: Hugely simplifying your code, note what happens with/to the sHTMLTemp variable: $sHTMLTemp = ""; while ($unirow = mysql_fetch_array($uniresult)) // Where $result is your result set { if ($temp != $unirow['number']) { $sHTMLTemp = preg_replace("/(.+),/","\\1",$sHTMLTemp); print $sHTMLTemp ; print "</tr>"; $sHTMLTemp = ""; } /* Lots of putting stuff into sHTMLTemp */ } /* -- END WHILE -- */ On change of "number", you print out the sHTMLTemp variable and clear it down, ready to be loaded with the next Player's data. When you get to the end of the loop, though, It's all set up with the last player's data ... but you don't actually print it out! Regards, Phill W.
  2. This is actually quite an informative error message: "Too few arguments to function curlCall() ..." "... 1 passed in /clientzone/modules/products.php on line 33" "... at least 2 expected in /clientzone/includes/functions.php:0" You've defined a function curlCall that takes "at least 2" arguments . You're now calling that function with only 1 argument. Bzzzt!! PHP says "No". Regards, Phill W.
  3. No. It doesn't do anything at all with slashes. As I said: So your file might look like this ... ... and, if you entered "apple", the code would generate the link: <a href="https://blabla.com/blablabla/blablablabla/apple" target="_blank" rel="noopener noreferrer">apple</a><br/> If you are expecting multiple links to be generated based on what you enter, then please explain how you would expect this to work. Regards, Phill W.
  4. As given, the code loops through each line in the file, looks to see if that line contains the entered word and, if so, displays that line on screen, effectively creating the HTML link (because that's what each line of the file is!). It's a really clumsy way of doing this, because The links are hard-coded in the file, making them difficult to maintain, and The test (strpos) will find the given word anywhere in line, so if you were to enter the value "target", it would match each and every line! A simpler and safer way might be to hold just the words in the file, without all the HTML stuff, and search that, then create the HTML for the selected line: . . . $found = false; foreach ($lines as $line) { if ($line === $search) { $found = true; printf( '<a href="https://blabla.com/blablabla/blablablabla/%s" target="_blank" rel="noopener noreferrer">%s</a><br/>', $line, $line ); break; } } // If the text was not found, show a message if (!$found) . . . Regards, Phill W.
  5. What does the generated HTML look like (Use the "View Source" tool in your browser). Remember that your PHP is effectively just building a String that gets sent to the browser for it to make sense of. Copy the link URL out of the browser and make sure that that it works on its own. It may simply be that $row['linkpage'] isn't a valid URL. Regards, Phill W.
  6. One of the [Unwritten] Rules of Relational Databases: Rows in a Table have no intrinsic order. The only way to guarantee the order is to use the "order by" clause on your select statements. select sub, ... from table1 order by sub ; As Requinix quite rightly said - store numeric data values in a fields with a numeric Data Type. Regards, Phill W.
  7. Indeed it can and it absolutely should have. However, whilst an item should legitimately have a name and an id, you appear to also have given [one of] yours an Id. DOM navigation is case-sensitive, so ... "id" != "Id" ... and GetElementById only uses id. Something more like this: <td><input type="text" id="item1sum" value="" name="item1sum" placeholder="item 1 sum"></td> Attribute names (id, value) are case-sensitive and may appear only once within each Element. Pick one id for the element and stick to it. Use CSS for styling, rather than hard-coding it into every element. Regards, Phill W.
  8. item1cost and otem1charge are both String values, taken from the "value" property of the Element. Performing arithmetic on them may or may not work as expected. Better to convert them (parse* functions) to the correct Data Type first. There's no need for the ".value" bit on the totalcharge line. You're not reading a DOM Element property here - just working with variables. You're not actually displaying the calculated value! document.getElementByid('item1charge').innerText = "Total Charge = " + totalcharge ; Setting InnerHTML is risky - it leaves your site open to Cross-Site Scripting Attacks. Regards, Phill W.
  9. I would say no. The displaying of the form and it's processing are closely coupled. There's not much benefit in splitting them out into separate files. Just because you process the data before displaying the form doesn't mean that the code to do that processing has to go first in the file! Call a function that does the work. That function can be defined anywhere in the file. Also, there are limits on the number of redirects you can chain together, so why introduce another one when you don't need it? Regards, Phill W.
  10. You must not send anything back to the browser before issuing the redirect. No HTML tags, not even whitespace. In the code you show, you're sending most of the form before issuing the redirect. It's conventional to do the POST processing first, then render the rest of the Page if the User is still "here". something like this: if ( Posted_Data_Present() ) { ProcessPostedData_IncludingAnyRedirects(); } DisplayForm_IncludingPostedData(); Regards, Phill W.
  11. Never use the root (or any other "superuser") account for running applications. These uber-powerful accounts should be kept solely for your use to clean up the mess when an Application goes wrong. Keep the Biggest and Best tools in the toolbox for yourself. Create an account specifically for the application to use and grant that account only the permissions that it needs to do its job. +1 for not showing us your [root] password. -1 again, though, for hard-coding it into your PHP source code. Database credentials need to be carefully guarded and having them lying around in plain text, even in a PHP file, is not a Good Idea. All that said, we have no idea why your "index file is not opening" ... you've shown us no PHP code to examine, nor [database or PHP] errors to diagnose. Details, details, details ... 🙂 Regards, Phill W.
  12. This XPath expression will find a product if it is is stock and return no items if it's not. $items = $xml->xpath( "/ STOREITEMS / PRODUCT [ @ITEM = '$product_queried' and STOCK / text() = 'In Stock' ] " ); Regards, Phill W.
  13. Add this condition into your "select" statement so that it only retrieves the relevant items for displaying. Don't retrieve everything and then filter it in PHP code. Regards, Phill W.
  14. At it's most simplest, your solution is called an "If statement". The HTML page loaded into the User's browser submits data to your PHP for processing. As as essential part of that processing, you should validate the supplied data values against your chosen criteria. In this case, they need to enter a valid [Character Representation of a] Date that must be earlier than the current date. If the supplied data does not match your criteria, then you send error back message(s) that the HTML (or Javascript) has to show to the User. Regards, Phill W.
  15. This is an environmental issue between your local server and your Production one, i.e. something is set up differently between the two. That require() statement is telling PHP to go and read the contents of some file and to fail if it cannot find that file. The file is specified in the variable, $view. To what value is this variable set to on your local server? Where does the PHP code set that value? Regards, Phill W.
  16. From what you've shown? No idea. What does the trValue() function do? Please remember - you are looking at this problem all the time. We only get to take the most cursory of glances at it during a quiet[er] half hour or over the lunch-hour. We are not psychic. (Some people around here are really Good, but none of us are that Good!) 🙂 We don't know what code you've written since your last posting - for example, this "$details" thing has appeared. Regards, Phill W.
  17. Simpler than you might think. The foreach loops through the array, giving you the key and value of each item in turn. For every item, you want to insert the Table Row construct. For the item where the key is "ct", you want to insert some extra "stuff". Try this: foreach( $arr as $k => $v ){ $x .= sprintf( '<tr><td> Td %s </td><td> Td %s</td></tr>', $k, $v ); if ( 'ct' === $k ) { $x .= $Insert_HTML_Here ; } } Regards, Phill W.
  18. PHP has a handy strtotime() function that does exactly that. Since you're [still] building your SQL dynamically, you do need to worry about how to format the Date Literals in your SQL. Ideally, you should use Parameterised Queries that will take care of this for you but, as you're not there yet, you need to format the Date literal to ensure no ambiguity when passing it to the database. $yfrom = date( 'Y-m-d', $dateTimeValue ); $yuntil = date( 'Y-m-d', $dateTimeValue ); $queryfebus = "SELECT x, y, z FROM glamm_pedidos WHERE fecha_folio BETWEEN '$yfrom' AND '$yuntill' "; Also, make sure that the columns in your database tables really are a Date Data Type. All too often, we see people complaining about the "format" of the Dates in the database tables. One of the "Rules" or Relational Databases: Dates have no format. None that you or I need to worry about, anyway. If you think that your Dates have the "wrong format", then the chances are that you actually have Character data that just happens to look like Dates. That's never a Good Thing and will cause you all kinds of grief. Regards, Phill W.
  19. Obligatory XKCD reference: Little Bobby Tables Regards, Phill W.
  20. The problem is common to Users, everywhere. Provide them with a mechanism to reset their own password and it becomes their problem entirely. MD5 is completely broken. Update to something at least vaguely secure. Until somebody spends an afternoon and works out your "Magic Method" and then all of your formulaic passwords are laid bare. Attempting to roll your security system is almost always a Fools Errand. Far better to randomly seed their password. Oh really? Anything that identifies a Data Subject is considered Personal Data and you are storing two of them right here. id. Uniquely identifies each Student. OK, probably not much use on its own, but in context with other information, this could be used to identify, locate or track an individual. name. Just how Personal does Data have to get? Regards, Phill W.
  21. Is the value actually blank or does your web browser display it as "blank", by trying to interpret the value as HTML? Either escape [the characters in] the value, preventing it from being shown "as" HTML or use your browser's "Developer" tools to examine the value - that will allow you to see "raw" value. Accepting Html-like values in this way can be extremely risky. It's all too easy for a [malicious] client to slip in <script> tags which, if you display them without proper "protection" will execute that script code! Regards, Phill W.
  22. OK, you've created a PHP String variable that just happens to contain some text that your DBMS can make sense of (i.e. you've written some SQL). As others have said, it's very risky SQL, as it stands, but it's still SQL. But it's still only a String variable. You need to tell your database to do something with it (i.e. to execute it). Regards, Phill W.
  23. I think you may have had a "Lucky Escape" here. Your code failed on the "select". It might be that you have a "delete" statement a few lines further down ... If so, you would have been removing "real" Data from your Live database! You need to find a way to prevent this "cross-Environment" connectivity from happening again. Regards, Phill W.
  24. Why do you feel the need to? IPv6 is already here and gaining in usage. Let's face it, there are only so many IPv4 Addresses and more devices coming on line every day. There will come a time when IPv4 will be is phased out. Why would you want to deliberately future-fail your code by locking it into this older protocol? There is no effective difference between "127.0.0.1" and "::1". It's the [loopback] address of the local machine and, once your Application goes out onto its real server, your Application will, most likely, never see it again, anyway. No real difference? Well, some of us might have to go buy a new T-Shirt to replace the one with this message: 😉 Regards, Phill W.
  25. If the user has never voted, then all of the individual votes values will be NULL. If all of the values given to SUM() are NULL, then the result is also NULL. You may want to add code to your query to handle this case. I think ... IFNULL( SUM( votes ), 0 ) ... will do what you want. Regards, Phill W.
×
×
  • 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.