|
Oh, I'm not worried about that, I've got a pretty solid idea of what my site needs to do, and every component that the framework uses is optional. The framework merely gives me the ability to do things quickly that I would have to code otherwise. Anywho, is there a function to encode an array to a string/binary thing (like json_encode, but native/really fast) - I want to save an array to a database, but encoded. Cheers. Rat Supremacy fucked around with this message at 19:27 on Aug 13, 2009 |
# ? Aug 13, 2009 19:17 |
|
|
# ? Jun 5, 2024 06:46 |
|
I like that, a lot. I'm trying to think of how I'd convert my current data records to that kind of system and am coming up short, though. Basically, it looks like any datapoint that you have that can be manipulated at all - even just converting between decimal and lb/oz - is a separate object. Thus, making each object only handle one kind of thing. Which I suppose is the essence of single responsibility. All the database stuff is in shipments? So when you want to change an address, the database code is in Shipments but manipulates the Address object?
|
# ? Aug 13, 2009 19:17 |
|
haywire posted:Oh, I'm not worried about that, I've got a pretty solid idea of what my site needs to do, and every component that the framework uses is optional. The framework merely gives me the ability to do things quickly that I would have to code otherwise. http://www.php.net/serialize
|
# ? Aug 13, 2009 19:24 |
|
jasonbar posted:http://www.php.net/serialize Ah thanks, I knew this existed, I just couldn't remember the name. How does it rate performance wise with json_encode? Edit, turns out json_encode is faster. However, it lacks features that serialize gives you. I'll try and see if I can make do with json_encode, but move to serialize if it doesn't work out. Rat Supremacy fucked around with this message at 19:33 on Aug 13, 2009 |
# ? Aug 13, 2009 19:28 |
|
Golbez posted:I like that, a lot. I'm trying to think of how I'd convert my current data records to that kind of system and am coming up short, though. Basically, it looks like any datapoint that you have that can be manipulated at all - even just converting between decimal and lb/oz - is a separate object. Thus, making each object only handle one kind of thing. Which I suppose is the essence of single responsibility. Not everthing has to be an object. For instance a shipment has a plain old ID field, some reference fields which are just plain old strings, etc. You only need to use an object where it makes sense. Basically the Weight would work like this in PHP (there is a lot more functionality in C#) code:
code:
Begby fucked around with this message at 20:01 on Aug 13, 2009 |
# ? Aug 13, 2009 19:56 |
|
KuruMonkey posted:If it works in one browser and not another then the issue has to be in the rendered html of the form. It can't be in your form handling/emailing code as thats not run in the browser. Thanks man. Turns out I just needed to walk away for a bit. Got home, noticed an errant /p after the form, removed it, and somehow it works. Not sure if that did it or something just "clicked" during a copy/past into a test page.
|
# ? Aug 13, 2009 20:05 |
|
Many of my most intractable coding troubles have resolved themselves while I waited for the kettle to boil
|
# ? Aug 14, 2009 16:56 |
|
Why can't I get this simple script to work? All I want to do is take an image from a URL and store it to a folder on my server. The folder has the correct permissions and I've tried a manual image uploader to that same folder and it works. I've also wrote $fp as open('http://www.majoroutput.com/sonicCircus/images/', 'w'); (without the filename). php:<?php $contents = 'http://www.majoroutput.com/sonicCircus/test.jpg'; echo "<img src='".$contents."'>"; $fp = fopen('http://www.majoroutput.com/sonicCircus/images/test.jpg', 'w'); fwrite($fp, $contents); fclose($fp); ?> LP0 ON FIRE fucked around with this message at 23:26 on Aug 14, 2009 |
# ? Aug 14, 2009 23:02 |
|
So I finally realized what was causing so many problems for me with my site: The MySQL databases were all set to version 4.0, not 5.0. Gah. Question is, does the upgrade to 5.0 really change anything? Is it worth the hassle of figuring out what exactly is different and what isn't? I may have to go over the ENTIRE SITE and check EVERY mysql line to make sure it works in 5.0, and I really don't want to have to do that id I don't need to.
|
# ? Aug 15, 2009 00:08 |
|
awdio posted:Why can't I get this simple script to work? All I want to do is take an image from a URL and store it to a folder on my server. The folder has the correct permissions and I've tried a manual image uploader to that same folder and it works. http://php.net/fwrite
|
# ? Aug 15, 2009 00:15 |
|
waffle iron posted:Are you trying to use the http file io wrappers to write? If all these files are on your webhost, why don't you just use copy? It also looks like you're passing the wrong arguments to fwrite. I'm just using files on the same host as a test. I've tried off the site too. I've seen multiple people mention using fwrite to get offsite images and save them to your host, including: http://www.webmasterworld.com/forum88/374.htm
|
# ? Aug 15, 2009 02:28 |
|
awdio posted:I'm just using files on the same host as a test. I've tried off the site too. Do your fopen, etc... functions have access to the URL wrappers? http://us.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen Additionally, $fp = fopen('path/to/local/file/not/remote/image.jpg', 'w'); You would want something like: php:<? $contents = file_get_contents($the_url); $fp = fopen('/my/images/dir/filename.file_ext', 'w'); fwrite($fp, $contents); fclose($fp); ?> Edit: nvm, I don't know if the comment I had here would work, and if it did work it would be a terrible idea anyway. jasonbar fucked around with this message at 04:59 on Aug 15, 2009 |
# ? Aug 15, 2009 04:49 |
|
I'm doing what you wrote: defining $contents with file_get_contents and putting the URL into a variable, if that does anything. Doesn't work.
|
# ? Aug 17, 2009 06:25 |
|
You could try curl:php:<? function tryGetURL($url, $dest) { global $errOpen,$errClose; $ch = curl_init($url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $reply = curl_exec($ch); $status = curl_getinfo($ch); if($status['http_code'] == 200) { if(($file = fopen($dest, 'wb', false)) !== false) { fwrite($file, $reply); fclose($file); } else die("Found the file but couldn't copy it to '$dest'"); } return ($status['http_code'] == 200); } ?>
|
# ? Aug 17, 2009 15:40 |
|
Sorry for making this go on so long, but it seems like I cannot get any methods to work. The only things that are disabled php-wise are Virtual Directory Support and Thread Safety. I double checked with my host 1&1 to see if anything with their settings would prevent this and they claimed that it wouldn't. Munkeymon - the curl script up above with the url and dest defined is returning a blank page without the message "Found the file but couldn't copy it to '$dest'". There's nothing in my images folder. The url for images work whether it's on or offsite. The destination folder to the images is correct. The permissions to the folder are correct. I've tried deleting the folder and creating one again and set the permissions again. edit: I even tried using ftp code. It prints 'Could not create the file'. php:<? $ftp_user = 'user'; $ftp_pass = 'pass'; $ftp_server = 'myserver'; $ftph = ftp_connect($ftp_server); $path = '/'; $ftpc = ftp_connect($ftp_server) or die('Could not connect to FTP server'); $jpg = file_get_contents('http://www.siteWhereJPGLives.com/image.jpg') or die('Could not grab the file'); ftp_login($ftpc, $ftp_user, $ftp_pass) or die('Could not log into FTP'); ftp_site($ftpc, 'CHMOD 777 ' . $path) or die ('Could not CHMOD the directory'); $fp = fopen('http://www.mySite.com/imagePath/test.jpg', 'w+') or die('Could not create the file'); fputs($fp, $jpg) or die('Could not write to the file'); fclose($fp); unset($jpg); ftp_site($ftpc, 'CHMOD 777 ' . $path) or die ('Could not CHMOD the directory'); ftp_close($ftpc); ?> LP0 ON FIRE fucked around with this message at 20:04 on Aug 17, 2009 |
# ? Aug 17, 2009 18:20 |
|
You can't use fopen to WRITE to a url.
|
# ? Aug 17, 2009 21:30 |
|
awdio posted:Munkeymon - the curl script up above with the url and dest defined is returning a blank page without the message "Found the file but couldn't copy it to '$dest'". There's nothing in my images folder. The url for images work whether it's on or offsite. The destination folder to the images is correct. The permissions to the folder are correct. I've tried deleting the folder and creating one again and set the permissions again. You would have to check the returned value from the function. If it's false, the remote server returned something other than a 200 (success) like maybe a 404 (file not found). You can always just change the function to var_dump($status) to see what happened.
|
# ? Aug 17, 2009 21:36 |
|
Dear PHP devs, what in the logic is removing the <?= shortcut along with the the <? shorttag? The <?= will not be confused with <?xml, and it is very useful for using php to template. Which mailing list should I start a campaign on to have it reinstated?
|
# ? Aug 19, 2009 20:47 |
|
None, because It's Not The PHP Way. Get out while you still can.
|
# ? Aug 19, 2009 21:16 |
|
haywire posted:Dear PHP devs, what in the logic is removing the <?= shortcut along with the the <? shorttag? The <?= will not be confused with <?xml, and it is very useful for using php to template. HAHAha, gently caress. Why isn't an XML parser operating on a PHP file pretty much always a logic error that the language designers shouldn't care about? McGlockenshire posted:Get out while you still can.
|
# ? Aug 19, 2009 21:51 |
|
McGlockenshire posted:None, because It's Not The PHP Way.
|
# ? Aug 19, 2009 22:22 |
|
This is probably a fairly simple/beginner question that I should know the answer to but I'm dealing with a php form that isn't mine, specifically: http://www.registrar.usf.edu/ssearch/staff/staff.php and I'd only like to give a value to one variable "P_REF" which refers to the text box input for "Course Reference Number". What I'd like to do is, instead of manually typing in the course reference number, I'd like to state it in the url and automatically submit it if possible. For instance, it's probably impossible to do something like "http://www.registrar.usf.edu/ssearch/staff/staff.php?P_REF=11962&Search" or something like that unless it was originally written in the server side code to query the URL? Now I am aware that the following may sound very stupid BUT: if that's an impossibility, is it possible for me to create my own php page (hosted on my own server) where I would set P_REF = 11962 then point my form action toward http://www.registrar.usf.edu/ssearch/staff/staff.php to create the same effect with one mouse button? Basically you can see that I would like to automate filling out this form so that with a single click I get the results of my query. So if either of my methods are impossible and there's an alternate, I'm open to another method. Thanks in advance for any help.
|
# ? Aug 20, 2009 01:00 |
|
haywire posted:Dear PHP devs, what in the logic is removing the <?= shortcut along with the the <? shorttag? The <?= will not be confused with <?xml, and it is very useful for using php to template.
|
# ? Aug 20, 2009 01:45 |
|
Pimpsolo posted:Basically you can see that I would like to automate filling out this form so that with a single click I get the results of my query. So if either of my methods are impossible and there's an alternate, I'm open to another method. Thanks in advance for any help.
|
# ? Aug 20, 2009 05:02 |
|
gibbed posted:I don't know (or care) about the echo tag, but I always disliked the short tag because it was a toggleable option to have it enabled or not. Indeed; its all about portability. Some installs will have short tags enabled, and some not, so code using short tags will fail to run on some systems. All PHP installs will handle long tags, so anyone who cared about other people being able to use their code without having to reconfigure their server already only used long tags. Also some of the servers configured without short tags are ye olde shared hosting, making it difficult to do that reconfiguration. tldr; short tags were a silly idea, no one with any common sense will be sad to see them go.
|
# ? Aug 20, 2009 08:33 |
|
haywire posted:Dear PHP devs, what in the logic is removing the <?= shortcut along with the the <? shorttag? The <?= will not be confused with <?xml, and it is very useful for using php to template. i always enjoyed writing <<??>?xml
|
# ? Aug 20, 2009 08:36 |
|
KuruMonkey posted:tldr; short tags were a silly idea, no one with any common sense will be sad to see them go. No it loving wasn't, making them an option was. But then again this is one in a long line of not-quite-right solutions to not-quite-right problems php has, so any php dev has seen some of their favorite parts go to waste. Yeah so I love short tags, so shoot me.
|
# ? Aug 20, 2009 09:37 |
|
I would like to know what the best procedure to authenticate between a Java and PHP application would be. There is a php webapp at php.example.com that uses PHP sessions and there is a java webapp at java.example.com. I would like to be able to log in to the php site and then pass that authentication on to the java site. I'm thinking something like add an extra cookie from the php site set to example.com and then use a web service to authenticate to some DB that the PHP session gets stored in.
|
# ? Aug 20, 2009 19:57 |
|
Murodese posted:i always enjoyed writing <<??>?xml <? isn't important. <?= is kind of loving neat, though.
|
# ? Aug 21, 2009 00:18 |
|
I was digging through some Kohana code and came across this syntax, which I have never seen before:php:<? ($field === TRUE) and $field = $this->any_field;?> php:<? public function add_rules($field, $rules) { // Handle "any field" filters ($field === TRUE) and $field = $this->any_field; // Get the rules $rules = func_get_args(); $rules = array_slice($rules, 1); ... ?>
|
# ? Aug 25, 2009 14:12 |
|
It's the equivilent of:php:<? if ($field === TRUE) { $field = $this->any_field; } ?>
|
# ? Aug 25, 2009 14:22 |
|
SmirkingJack posted:I was digging through some Kohana code and came across this syntax, which I have never seen before: http://en.wikipedia.org/wiki/Short-circuit_evaluation doing it in the context of php:<? some_func() or die("some_func() returned an error!"); ?>
|
# ? Aug 25, 2009 14:34 |
|
gibbed posted:It's the equivilent of: Standish posted:this is called "short-circuiting". Ah, I see. Thanks for teaching me something new!
|
# ? Aug 25, 2009 14:52 |
|
gibbed posted:It's the equivilent of: php:<? if ($field == TRUE) $field = $this->any_field; ($field === TRUE) and $field = $this->any_field; ?>
|
# ? Aug 25, 2009 21:51 |
|
I'm using the below function to replace certain words with a html formatted version of the same word. The html formatting is actually just surrounding the word with a span tag that I use with jQuery to pop up a description of the word. Basically this: code:
code:
Lets say the dictionary contains two words: "Consectetuer" and "Quisque". First the function will put a span tag around "Consectetuer" but then it will also put a span tag around "Quisque" which occurs within the description (that was just added by the previous "iteration" of preg_replace) for "Consectetuer" and gently caress everything up. I'll end up with this: code:
php:<? function dictionaryTest($s) { $resDic = query("SELECT * FROM dictionary WHERE groupid = ".ACTIVE_GROUP." ORDER BY word"); if (mysql_num_rows($resDic)) { while ($dicWord = mysql_fetch_assoc($resDic)) { $arrPatterns[] = '/\b('.$dicWord['word'].')\b/U'; $arrReplacements[] = '<span class="dicWord" title="'.htmlspecialchars($dicWord['word']).'|'.htmlspecialchars($dicWord['descr']).'">$1</span>'; } return preg_replace($arrPatterns, $arrReplacements, html_entity_decode($s,ENT_NOQUOTES,'UTF-8'),1); } else { return $s; } } ?>
|
# ? Aug 27, 2009 09:44 |
|
Dump the word replacement list to an associative array ('word' => 'explanation'), explode the output text on space, go through the array of output text and see if each entry appears in the replacement array and if it does, replace the entry in the output array with the tags and whatnot then implode the output array to get the whole text again. I imagine one of the mysql_ functions would make dumping the text into a PHP array easy (possibly a one-liner?) but I don't know because we use our own horrible custom middleware here at work so I never use them. Also, you know there's an acronym tag? http://www.w3schools.com/tags/tag_acronym.asp
|
# ? Aug 27, 2009 14:01 |
|
KuruMonkey posted:tldr; short tags were a silly idea, no one with any common sense will be sad to see them go. what? <?=$my_var?> is so much cleaner than <?php echo $my_var?> Do you like writing '<?php echo' 40 times in a file?
|
# ? Aug 29, 2009 00:19 |
|
I have a client that wants some control over his databases for his site (viewing, creating, and modifying data in tables etc.) without any knowledge of SQL. I did the site in MySQL. Is there was a premade script for this kind of thing or do I have to start from scratch?
|
# ? Aug 29, 2009 01:10 |
|
scrabbleship posted:I have a client that wants some control over his databases for his site (viewing, creating, and modifying data in tables etc.) without any knowledge of SQL. I did the site in MySQL. Is there was a premade script for this kind of thing or do I have to start from scratch? Would http://www.phpmyadmin.net/home_page/index.php work?
|
# ? Aug 29, 2009 01:35 |
|
|
# ? Jun 5, 2024 06:46 |
|
jasonbar posted:Would http://www.phpmyadmin.net/home_page/index.php work? It might but it is probably a bit overkill for what my client wants. This would probably overwhelm him. He just wants something he can see the entries in the table with and modify/delete faulty ones with; nothing to fancy. Thanks for the suggestion nonetheless.
|
# ? Aug 29, 2009 02:11 |