Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by dalecosp

  1. +1 for a development environment. I use Oracle's Virtualbox and install a BSD-family OS with Apache+PHP ... you might be able to even find a Docker container or something like that for free out there someplace. As far as what will happen, the biggest recent changes to PHP, in terms of effect, at our company were removing the old mysql_* stuff (although most of it was long gone, we found out that some infrequently-used LAN software and reports still had some mysql_* stuff in them, and the removal of mcrypt().
  2. Drag 'n drop is done with an AJAX system; a JavaScript front-end script packages the image data into a FormData object, and the AJAX operation will POST that to a PHP handler script on the server, which then does the work to put it someplace just like we did in the Elder Days when we used a basic upload form in HTML. So, at the very least you need two scripts, one PHP and one in JS.
  3. It would also be possible to post-process all the URLs on the page with JavaScript, but who wants to take time to do THAT?
  4. Pretty URLs are fairly simple. Either use mod_rewrite (for Apache servers) or its equivalent on your system to do the complete work, or use it to redirect to a centralized script that reads the URL parameters and shows content based on that parameter. At work, we have listings like: www.ombe.com/listing/2151404/Uninet-Developer-for-use-in-Ricoh-Aficio-200,-250,-345g mod_rewrite has this rule: RewriteRule ^listing/([0-9]+)/?.*$ listing?$1 [NC,L] "Listing" does something like this: $product_num = intval($_SERVER['QUERY_STRING']); Of course there's a LOT more, config and
  5. The quid pro quos of going to "MySQLI" include changing your connection string and the query syntax. The one big "gotcha" to me when converting old to new (MySQL to MySQLI) was the lack of a mysqli_result() function in the older days, but now you can do something like this: $data = $result->fetch_row()[0]; ... which seems fairly handy to me in place of mysql_result. I'm not sure when this syntax became valid, off the top of my head. PDO is generally touted as great for security and portability. I'm not totally convinced, but the use of prepared statements is preferable to its a
  6. There are three echo() constructs that would produce output. A fourth such construct is commented out so it won't run. echo $data[$j]; echo ","; echo "<br>"; If you'd like a space after the comma, add a space after the comma in the 2nd echo shown above. If you're viewing this program's output in a browser, the "<br>" should produce a lineBReak. If you're not, it will just be so much garbledy-gook. Probably this line: //echo "n" Was actually mean to write a 'newline', like this: echo "\n"; Enabling (uncommenting) that line (with the change as
  7. Just for additional info, MySQL's max_connection variable has a lower limit of 1 and a max limit of 100000, and the default value for all recent versions of MySQL is 151. We run max_connections=250 on a VM that hosts 4 sites with moderate traffic and about 60 more that get very little. We occasionally have "too many connections" errors, generally when some bot comes by that doesn't read Robots.txt (or a new one that we've haven't added there).
  8. Instead of just dumping mysqli_error(), also dump the statement you tried to make. See if you can see why it wouldn't work. If necessary, try it against a test database.
  9. <?php $foo = "Foobar"; echo "$foo"; // Foobar. echo $foo; // Foobar. Functionally equivalent to above, no quotes needed. echo '$foo'; // $foo. A literal string, and not what we wanted. $foo = "/home/dalecosp/php"; file_put_contents($foo . "/" . 'bar', "This is file content"); // writes the given sentence into /home/dalecosp/php/bar. file_put_contents("$foo/" . "bar", "This is file content"); // does the same thing; because of double-quote variable interpolation, the trailing slash is added to /home/dalecosp/php (it was not given when $foo was assigned). file_put_contents("$fo
  10. Welcome to PHPFreaks! There sure are some around here.
  11. Google Translate works for me! (For some subset of languages we're interested in, that is....)
  12. Goodness gracious, great balls of AJAX! What in God's green earth are you selling? Because if it's not blow, crypto-currency or heavily-discounted precious metals ain't no one got time to load a page with one data item on it.
  13. That might be worth a try. You'd have to be careful about where you put your labels ....
  14. Sounds an interesting use case. All in the same folder? 'Cause if the path is different, "config.php" (or 'myApp.ini' or something similar) at least has the distinction of being an appropriate name for a configuration file. I once created 65 sites in one day using logic files, templates, and a config munger that changed "config.php" to contain appropriate defaults for the DOCROOT they were in. One of my proud "not proud" moments, I guess. ??
  15. I'm not sure I understand 100% ... loop them for creation or reading? For reading, you'd need to know the element's name attributes (from the HTML) when processing the data in the handler script.
  16. Well, can you put them in the form somehow? Traditionally that might be done with <input type='hidden'>, if it's not possible to move the <form> tags to the appropriate locations. If you can't do that, I'm not sure what to tell you, because that sounds like front-end type magic (AJAX). Well, I kind of showed that in a more/less procedural style in my post above. If you want you could wrap that in a function; keep in mind you'd need to either declare $db to be global or establish a connection (or connection object) INSIDE your function. As Barand showed you, PD
  17. He's just telling you how to get the ID of the last inserted row. You wrote pseudo-code, so that's not the only thing you need help with, I'd expect? Here's your pseudo-code with comments that I hope will help. I'll post again with some direct answers to your two points, above. <?php # First off, your code is accepting $_POST data at face value. # An attacker might be able to do something evil with that. # # Next, where's the SQL connection happening? I'll do a mysqli ... $db = mysqli_connect("localhost", "user", "pass", "db_name"); # NOTE: I don't do ANY error checking in this
  18. Another good font, free ... "Gonville", by Simon Tatham: https://git.tartarus.org/?p=simon/gonville.git
  19. Indeed, welcome to PHPFreaks ... ?
  20. Yeah, but does anyone ever actually punch it .... and follow through? Congrats, Maxxd ... I'm sure you'll be a tip-top rep for the community :-)
  21. NULL is trouble. In PHP it's approximately zero, it's special in the DB and requires that you use differrent syntax to set and/or check for it. Avoid it when possible and use some other value (like 0).
  22. Noteflight.com Bet they wrote a ship-load of JS for that ....
  23. http://music-theory.com/fonts.html Petrucci, Marl, Tufa. Petrucci was in the first versions of Sibelius back in the 1990's. You could download these and put them in a folder on your site; then, in CSS: @font-face { font-family: Petrucci; src: url(fonts/pe.ttf); }
  24. An an extra hint, glob's return type is array
  • 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.