|
Golbez posted:Another crazy-rear end question... Unfortunately no. That will give a syntax error. You need to assign the array to a variable and then refer to an offset of that variable, as you did in your second example.
|
# ? Aug 2, 2010 14:44 |
|
|
# ? May 31, 2024 22:21 |
|
Hammerite posted:Unfortunately no. That will give a syntax error. You need to assign the array to a variable and then refer to an offset of that variable, as you did in your second example. Thanks. I had a feeling there was no way but I wanted to check.
|
# ? Aug 2, 2010 14:51 |
|
Another quirk I just ran across:code:
code:
|
# ? Aug 2, 2010 17:31 |
|
Hammerite posted:Unfortunately no. That will give a syntax error. You need to assign the array to a variable and then refer to an offset of that variable, as you did in your second example. Well, if he doesn't want to keep the array, he can use a different function to extract the value: code:
|
# ? Aug 2, 2010 17:36 |
|
Munkeymon posted:Well, if he doesn't want to keep the array, he can use a different function to extract the value: Yeah, I had no interest in the rest of the array (it was the return from getimagesize, I was interested only in the mimetype, though since then I've wanted to also get the actual dimensions, so it's no longer a relevant issue), so I was hoping there was a simple way to call the function and immediately get an array value out of it, then discard the array, in one line. I suspect, if such a thing were possible, there'd be a lot of people who would have already learned to combine mysql_fetch_assoc with a return. I know I would enjoy being able to do "return mysql_fetch_assoc($result)['actual data i'm looking for']".
|
# ? Aug 2, 2010 17:43 |
|
Golbez posted:I suspect, if such a thing were possible, there'd be a lot of people who would have already learned to combine mysql_fetch_assoc with a return. I know I would enjoy being able to do "return mysql_fetch_assoc($result)['actual data i'm looking for']". Fat chance, because that would be too expressive and thought out.
|
# ? Aug 2, 2010 19:48 |
|
Does anyone have any experience with this class for sending SMS via php using Google voice? Any better ideas for sending them? I haven't found any free gateways, and it seems trivially easy to sign myself up for Google Voice. Thoughts?
|
# ? Aug 3, 2010 03:38 |
|
Sub Par posted:Does anyone have any experience with this class for sending SMS via php using Google voice? Any better ideas for sending them? I haven't found any free gateways, and it seems trivially easy to sign myself up for Google Voice. Thoughts? Is there a problem with using this to send through google voice? It works well, I just tested it and it is pretty straight forward.
|
# ? Aug 3, 2010 03:44 |
|
DarkLotus posted:Is there a problem with using this to send through google voice? It works well, I just tested it and it is pretty straight forward. I haven't tested it yet - don't have a google voice account yet. Wanted to know if it all worked and wasn't a broken mess before I got started. I'm new to PHP and just wanting to make sure I don't inadvertently use a bunch of poo poo I regret later. Thanks.
|
# ? Aug 3, 2010 03:52 |
|
Golbez posted:Another crazy-rear end question... This will be possible in the next major version of PHP.
|
# ? Aug 3, 2010 05:34 |
|
Sub Par posted:I haven't tested it yet - don't have a google voice account yet. Wanted to know if it all worked and wasn't a broken mess before I got started. I'm new to PHP and just wanting to make sure I don't inadvertently use a bunch of poo poo I regret later. Thanks. Give it a shot, I looks like it will do what you want.
|
# ? Aug 3, 2010 13:16 |
|
McGlockenshire posted:This will be possible in the next major version of PHP. Now we just have to wait for the release, which has been in the works since... 2005? Depending on if it's 5.4 or 6.0...
|
# ? Aug 3, 2010 14:08 |
|
Golbez posted:I suspect, if such a thing were possible, there'd be a lot of people who would have already learned to combine mysql_fetch_assoc with a return. I know I would enjoy being able to do "return mysql_fetch_assoc($result)['actual data i'm looking for']". You could do this with PDO, something like code:
Also, try and stay away from references. Its just a quagmire in PHP. There is really no reason to use them, and references are slower in php anyways. You are better off using a little more code to read a session variable, then set it with a new value later.
|
# ? Aug 3, 2010 17:04 |
|
Begby posted:You could do this with PDO, something like [...] Begby posted:But you are really splitting hairs here. Yeah its nice to use that kind of stuff, but really whats a few extra lines of code?
|
# ? Aug 3, 2010 18:20 |
|
Yay posted:Honestly? As someone who used to work exclusively in PHP, when I need to come back to it from Python (which has had the feature for as long as I can remember),this is the kind of small thing I really miss (excusing the obvious warts of both languages). Yeah, I guess you are right. Now that I have migrated to mostly C# every time I go back to PHP I kinda want to shoot myself over stuff like this. Hopefully they improve the language, PHP certainly has its utility, hopefully it gets better.
|
# ? Aug 4, 2010 14:28 |
|
This is probably a mental block on being unable to find the proper function, but: I have an image stored in the database. I get that image out. Now, to display it, I simply run a few headers and then echo the variable. But what if I want to manipulate it first, create a resampled thumbnail for example? All of the imagecreatefrom* functions require filenames, I don't see any function for simply injecting data directly in. Will I have to write a file, then process that, or is there a way to create an image directly from a variable?
|
# ? Aug 6, 2010 20:50 |
|
Golbez posted:All of the imagecreatefrom* functions require filenames, I don't see any function for simply injecting data directly in.
|
# ? Aug 6, 2010 21:09 |
|
Yay posted:imagecreatefromstring doesn't. Well there we go, as I said, it was probably just a case of me missing the right command in the list. Thanks. Edit: Aha, but is it possible to get the image dimensions without writing it to a file and running getimagesize()? Golbez fucked around with this message at 21:50 on Aug 6, 2010 |
# ? Aug 6, 2010 21:13 |
|
Golbez posted:Aha, but is it possible to get the image dimensions without writing it to a file and running getimagesize()? No, I don't know why the functions are named as they are.
|
# ? Aug 6, 2010 22:19 |
|
Thanks again
|
# ? Aug 6, 2010 22:20 |
|
I've been away from PHP for quite some time, and I'm trying to get back into it by creating my own website. Anyway, index.php has been coded to call the following function:code:
code:
code:
And just to be thorough, here's what the function returns: code:
uh zip zoom fucked around with this message at 03:39 on Aug 7, 2010 |
# ? Aug 7, 2010 03:36 |
|
code:
|
# ? Aug 7, 2010 10:05 |
|
edit: ^^^ beaten and more concisely Maybe it works but I wouldn't think its good practice to mix an array as being part named, part unnamed. You have: php:<? $$navPages = array ("pageNames" => array (1 => "Home", "Blog", "Photos", "Links", "Contact")...); ?> Secondly, your index variable isn't properly used. You have ignored the $: php:<? $arrname["arritem"][i] // currently $arrname["arritem"][$i] // should have a $ ?> php:<? Function { $nav = "<ul>\n"; // \n will force a new line in the output code for ($i = 1; $i <= 5; $i++) { $nav .= " <li"; // The .= appends rather than replaces a string if ($currentPageFileName == $navPages["pagePaths"][$i]) { $nav .= " class=\"current_page_item\""; } $nav .= "><a href=\""".$navPages["pagePaths"][$i]."\">".$navPages["pageNames"][$i]."</a>\n </li>\n"; } $nav .= "</ul>"; return $nav; } $printnav = function(a,b); echo $printnav; ?>
|
# ? Aug 7, 2010 10:11 |
|
gwar3k1 posted:edit: ^^^ beaten and more concisely thank you so much you guys. I've been programming c# for the past three years, and coming back to php makes me feel like an old man just let out of a nursing home for a day pass... Edit: the only reason I named the first element in each nested array was because I wanted the index to start at one instead of zero, because it's easier for my peon brain to understand. uh zip zoom fucked around with this message at 19:34 on Aug 7, 2010 |
# ? Aug 7, 2010 19:23 |
|
I've always figured it's imageSX and imageSY (as in, image size x, image size y).
|
# ? Aug 8, 2010 23:26 |
|
I am attempting to create an update profile page on thie website, however I am having some trouble keeping multiple forms on the same page from affecting each other. here is some psudo code for what I want to do code:
php:<? if (isset($_REQUEST['submit2'])) { if($Password1 = $Password2) { code } } ?>
|
# ? Aug 9, 2010 17:55 |
|
DholmbladRU posted:I am attempting to create an update profile page on thie website, however I am having some trouble keeping multiple forms on the same page from affecting each other. Just use a hidden form field and give it a value. Then check the value in your form handler. As with all form data, it can easily be changed client side, so keep that in mind as far as security is concerned.
|
# ? Aug 9, 2010 18:06 |
|
Begby posted:Just use a hidden form field and give it a value. Then check the value in your form handler. php:<? <input type="hidden" name="password_Form" value="1"/>?> As far as security is concerened, should I pass the variable through php functions to ensure it doesnt contain sql injection or any slashs? DholmbladRU fucked around with this message at 18:26 on Aug 9, 2010 |
# ? Aug 9, 2010 18:18 |
|
DholmbladRU posted:
Each form has its own name, then check it. php:<? if(isset($_POST['password_Form']) && $_POST['password_Form'] = <value>) { doStuff; } ?> The security comment, I think, was to highlight the fact that a user doesn't have to submit the form to trigger the actions. They can trick the script into thinking a form has been submitted with the data they want sent. If anything is going into SQL statements, it needs to be sanitized first.
|
# ? Aug 9, 2010 18:35 |
|
I feel like an idiot, but I have been forced to parse an XML file through PHP, and never having had to work with XML before am failing horribly. After looking through dozens of xml namespace things, I still have no idea how to use them. All I know is that I can parse through regular nodes with $xml->children() but that doesn't work for getting the values of nodes with namespaces, or so it seems. I'm working with an xml file that I can't change. The top of the xml file has the xmlns defined... Do I need to do something else like register the namespace in my processing document? Do I have to make calls to xpath just to get the values? I am completely lost and the tutorials/documentation for this gets me nowhere... help?
|
# ? Aug 9, 2010 18:47 |
|
Okay, I got the seperate forms all worked out. Now what I am doing is echo infromation from the database into a table on the same page which a user can update his profile. Is there a way to make it so the page does not have to be manually refreshed, and will update the table. "to display the webpage again internet explorer needs to resend the information you've previouslly submitted" This message pops up when I manually refresh the page. DholmbladRU fucked around with this message at 19:10 on Aug 9, 2010 |
# ? Aug 9, 2010 19:06 |
|
DholmbladRU posted:Okay, I got the seperate forms all worked out. Now what I am doing is echo infromation from the database into a table on the same page which a user can update his profile. The method is called Post / Redirect / Get. I don't fully understand the PHP code for it, so I'll let you research it.
|
# ? Aug 9, 2010 19:27 |
|
DholmbladRU posted:Okay, I got the seperate forms all worked out. Now what I am doing is echo infromation from the database into a table on the same page which a user can update his profile. Your best bet would be to look into ajax if you don't want to refresh the page, though that can be quite daunting at first glance. For such a simple task, this might help.
|
# ? Aug 9, 2010 19:54 |
|
How are PHP developers these days managing data? I've got MySQL 5.1.something or other, and I would ideally like to use stored procedures. Reading the MySQL manual shows support for procedures, but when I try to run a raw SQL script to create one in phpMyAdmin, I'm getting errors. Would this belong in the SQL thread? Are PHP and MySQL as intertwined as they were five years ago?
|
# ? Aug 10, 2010 01:11 |
|
uh zip zoom posted:How are PHP developers these days managing data? I've got MySQL 5.1.something or other, and I would ideally like to use stored procedures. Reading the MySQL manual shows support for procedures, but when I try to run a raw SQL script to create one in phpMyAdmin, I'm getting errors. Would this belong in the SQL thread? Are PHP and MySQL as intertwined as they were five years ago? PHP and MySql aren't really intertwined at all, never really have been. Each runs just fine by itself. MySql is accessible by just about any language out there. We have been using Stored Procedures with MySql for a long time where I work. We have never touched phpMyAdmin though, only have ever used gui clients. MySql has a free one, my favorite though by far is EMS MySql Manager, but it does cost a bit. You can also write a script into a .sql file and run it on the command line if you are feeling adventurous.
|
# ? Aug 10, 2010 02:22 |
|
A hamburger? posted:After looking through dozens of xml namespace things, I still have no idea how to use them. All I know is that I can parse through regular nodes with $xml->children() but that doesn't work for getting the values of nodes with namespaces, or so it seems. Unfortunately that's the limit of my knowledge on the matter...
|
# ? Aug 10, 2010 02:59 |
|
uh zip zoom posted:How are PHP developers these days managing data? I've got MySQL 5.1.something or other, and I would ideally like to use stored procedures. Reading the MySQL manual shows support for procedures, but when I try to run a raw SQL script to create one in phpMyAdmin, I'm getting errors. You cannot call stored procedures in phpmyadmin, create a command line PHP script to perform unit tests. Or that's how I overcame the issue. The other mess is calling procedures in PDO, try to stick to parameters IN and objects or single returns out. php:<? $sth = $dbh->prepare ('CALL sp_category_get( :collections_name, :category_name )'); $sth->bindParam (':collections_name', $collections_name, PDO::PARAM_STR); $sth->bindParam (':category_name', $category_name, PDO::PARAM_STR); $sth->execute(); $sth->setFetchMode(PDO::FETCH_CLASS, 'PDO_Categories'); $category = $sth->fetch(); $sth->closeCursor();?>
|
# ? Aug 10, 2010 03:22 |
|
A hamburger? posted:I feel like an idiot, but I have been forced to parse an XML file through PHP, and never having had to work with XML before am failing horribly. Two pages ( maybe 3? ) ago in this thread there was some discussion on PHP, XML, and namespaces. I can't remember what the exact question / resolution was, but might be a good read to see if it helps in your case.
|
# ? Aug 10, 2010 04:29 |
|
Another GD question: So I've created an image resource with imagecreatetruecolor, and I've manipulated it with imagecopyresampled... now how do I get the image data into the database? Right now, I write the image back to the filesystem with imagejpeg, and then fopen/fread the data into a variable. Surely there's a way to skip that step? I don't think saving the resource will work, so how do I get the data out of the resource?
|
# ? Aug 10, 2010 17:24 |
|
|
# ? May 31, 2024 22:21 |
|
Golbez posted:Another GD question: So I've created an image resource with imagecreatetruecolor, and I've manipulated it with imagecopyresampled... now how do I get the image data into the database? Right now, I write the image back to the filesystem with imagejpeg, and then fopen/fread the data into a variable. Surely there's a way to skip that step? I don't think saving the resource will work, so how do I get the data out of the resource? Assuming $tmp is your image resource: php:<? ob_start(); imagejpeg($tmp, NULL, 100); break; // best quality $image_text = ob_get_contents(); ob_end_clean(); ?>
|
# ? Aug 10, 2010 17:48 |