-
Posts
15,227 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
You're doing file_get_contents() on a directory. Think about that.
-
Problems joining three tables and grouping by and having count
requinix replied to raymond_feliciano's topic in MySQL Help
Multiplication, not addition. 2 studies * 3 prescriptions = 6 rows. -
Yeah, that's about it. The rewriting turns the friendly URL into something that PHP can deal with (more easily), then the script uses $_GET and such to do whatever it needs to do.
-
You also need to manually chmod 0777 the parent folder (the one in which you're creating the uploads/ folder). Don't forget to change it back to 0755 when you're done.
-
You're calling htmlspecialchars() or htmlentities() too many times. The only time you should ever call those functions is immediately before you output something into HTML/XML. Not when you put stuff into the database. Not just after pulling it out. Right at the moment you echo or print out the strings.
-
Only the owner of a file can change its permissions.
-
Maximum execution time of 30 seconds exceeded
requinix replied to kranthy's topic in PHP Coding Help
That is one of the few error messages where the line number (generally) doesn't matter. Your script that times out - what does it do? -
To start with, /\*(\d+)\*/
-
Trying to get this PHP upload code to rename the file.
requinix replied to Vinlock's topic in PHP Coding Help
Uh yeah, I did too. $uploadDir + $targetFile = $targetDir, right? -
Which directory structure / naming convention do you prefer?
requinix replied to trq's topic in Miscellaneous
That's what I'd do. Not just for the name collision: if you used just one of those somewhere you'd have to alias it anyways because a name like "Standard" isn't helpful. use Proem\Service\StandardServiceManager, // unless there's a lot of Managers I'd remove the namespace level for them Proem\Signal\StandardSignalManager, Proem\Filter\StandardFilterManager; (though personally for those types of classes I prefer a -Base suffix over a Standard- prefix, like ServiceManagerBase, if even anything at all) -
Which directory structure / naming convention do you prefer?
requinix replied to trq's topic in Miscellaneous
I'm not sure how much I can comment on what you have now but I think I like the current structure more than the original. It took me a while to realize that namespaces aren't just about class paths but about grouping of classes; to take what I have as an example, /Mvc/Controls/Control.php (\Mvc\Controls namespace, Control class) makes more sense to me than /Mvc/Control.php (\Mvc namespace, Control class). Couple other miscellaneous comments on what I do: - I also name interfaces as IInterface and traits as TTrait (I'm writing for 5.4) so it's obvious what things are - I even name files as (class|interface|trait).name.php, but it's the first time I've done something like that so I might change that later I don't have very many files to show off as the current version of my framework is still quite young and very specialized, but here's my version of the original (and shorter) file list: /lib/Proem/Api - /Assets - class.Asset.php (abstract? base class of IAsset) - class.AssetManager.php - interface.IAsset.php - /Chains - class.Chain.php (abstract? base class of IChain) - class.ChainEvent.php - interface.IChain.php - /Events - class.Event.php (abstract? base class) - class.EventManager.php - /Utility - /Options - class.Option.php (abstract? base class) - class.OptionsCollection.php (convention I've borrowed from .NET) - class.Callback.php - class.Queue.php - class.Autoloader.php - Proem.php (sounds like a bootstrap/prepend file) -
Trying to get this PHP upload code to rename the file.
requinix replied to Vinlock's topic in PHP Coding Help
$targetdir is what you need to modify. Keep in mind that $uploadDir is just "/images/" and the $_FILES bit is just a filename (with an extension). -
Well... you don't need it. $first_number = $_REQUEST['price']; $second_number = 20; $sum_total = $first_number + $second_number; $direct_text = 'The two variables added together = '; print ($direct_text . $sum_total);
-
Why are you quoting the price as if it were about to go into a database? Because it's not about to go into a database.
-
Rewrite what and why?
-
Actually yes: look at the initial characters of the outputted hash (how many of which depends on the hashing algorithm). But you did notice that you can pass crypt() your own salt, right?
-
If the string actually includes "renderOptions" then you're pulling from the wrong page. You should be getting strictly JSON back: {"results":[{"locations":[{"latLng":{"lng":-112.35984,"lat":34.58752},.....
-
You wouldn't have to use eval() for it. Just access it through the window object. window["itm" + i].model Ah, the flexibility of JavaScript.
-
The namespace does add a bit of complexity, but it's still easier to deal with it than to use an array. $xml = new SimpleXMLElement( card 12345KKLS 709750ba-b9b6-44c4-9812 70 USD 2011-05-11T07:41:44.957 4 e0c66bae-c423-43c6-b896 50 USD 2011-05-11T07:42:13.55 2 XML , 0, false); $xml->registerXPathNamespace("ns", current($xml->getDocNamespaces())); $node = current($xml->xpath("//ns:Payment[ns:StatusID=4]"));
-
Just like in PHP, don't use multiple numbered variables - use an array. // create the various objects var porche = new Object(); porche.make = "porche"; porche.model = "boxter"; // put them into an array itm = [porche]; // then loop over it for (var k in itm) { $("#writer").append(itm[k].model + " "); }
-
Have you written any code to actually get the information from the database? What is it?
-
I myself am a fan of doing as much work in PHP as is reasonable, so $start = mktime(0, 0, 0); $end = mktime(23, 59, 59); $query = "SELECT * FROM contacts WHERE lastupdated BETWEEN $start AND $end";
-
That's an okay query if you get one day's events at a time. But it means ~30 queries just for that. SELECT * FROM calendar WHERE `date` >= first of the month AND `date` That will get you everything in one query. Inside your for loop you need to iterate over that resultset. Keeping the [code=php:0]$row_Recordset1 = mysql_fetch_assoc($Recordset1);
-
Well yeah. All your code does is get one single row. And it might not even be in the time range you're displaying. You need the right query, one that only pulls events from the database if they're on the calendar you're trying to show, and then you need some logic in the for loop to advance through the rows as you advance through the days. So what query do you think you should use? It needs a WHERE and an ORDER BY at a minimum.