Re: [PHP-DB] recover values independently of GET or POST used
bu...@alejandro.ceballos.info wrote: I am using some expressions to load the value of a parameter when called, independently if used GET or POST method, using something like: $mydata = (isset($_GET["mydata"])) ? $_GET["mydata"] : (isset($_POST["mydata"])) ? $_POST["mydata"] : 0; echo $mydata; ?> The problem occurs with above code if I call it like: thispage.php?mydata=something , the answer is null (not even '0'). You probably need extra ()'s around the post check: $mydata = (isset($_GET["mydata"])) ? $_GET["mydata"] : ((isset($_POST["mydata"])) ? $_POST["mydata"] : 0); Though that's hard to read - I'd suggest going back to basics because when you revisit this code in a few months time, are you going to understand it? -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] recover values independently of GET or POST used
Some weird stuff happens when you try to chain ternary operations. Not awake enough to explain it better right now. What it sounds lik eyou're looking for is $_REQUEST. This will give you the correpsonding GET or POST value (as well as cookie, environment, etc.. google it). It's probably good to try to structure things so you have a predictable and controllable way so you know whether you're going to be getting GET or POST data. Some cases required 'either' but in general, one or the other should be good enough if your code is structured properly. -TG - Original Message - From: bu...@alejandro.ceballos.info To: php-db@lists.php.net Date: Mon, 14 Sep 2009 19:41:24 -0700 Subject: [PHP-DB] recover values independently of GET or POST used > I am using some expressions to load the value of a parameter when > called, independently if used GET or POST method, using something like: > > $mydata = (isset($_GET["mydata"])) ? $_GET["mydata"] : > (isset($_POST["mydata"])) ? $_POST["mydata"] : 0; >echo $mydata; > ?> > > The problem occurs with above code if I call it like: > thispage.php?mydata=something , the answer is null (not even '0'). > > But If I change it to: > > $mydata = (isset($_POST["mydata"])) ? $_POST["mydata"] : > (isset($_GET["mydata"])) ? $_GET["mydata"] : 0; > > It works, but only with GET method, not post. > > > What is going on? > > Everytime must be an if/elsif/else routine? What is the origin of the problem? > > > TIA, > >Joal > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] recover values independently of GET or POST used
I am using some expressions to load the value of a parameter when called, independently if used GET or POST method, using something like: $mydata = (isset($_GET["mydata"])) ? $_GET["mydata"] : (isset($_POST["mydata"])) ? $_POST["mydata"] : 0; echo $mydata; ?> The problem occurs with above code if I call it like: thispage.php?mydata=something , the answer is null (not even '0'). But If I change it to: $mydata = (isset($_POST["mydata"])) ? $_POST["mydata"] : (isset($_GET["mydata"])) ? $_GET["mydata"] : 0; It works, but only with GET method, not post. What is going on? Everytime must be an if/elsif/else routine? What is the origin of the problem? TIA, Joal -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Need help-Send email
Hi Chris, Thanks for the response. However I have coded the Email code with SMTP authentication. But the problem is my mail is going to the SPAM not in the inbox. I remember someone has said that if the code is sending the email and if its going under SPAM folder then the code is correct but I have to work on client filter. I don't know how? Can you or anyone help me in this. Here is the code: \r\n"; /* Try to send message and respond if it sends or fails. */ if(mail ('ToPersonsName ', $subject, $body, $headers )){ echo "Your Message was sent!"; } else{ echo "Your Message Was Not Sent!"; } exit; ?>
Re: [PHP-DB] mysql_query returning empty result after DELETE
Stan wrote: OK. If I change the test to "if(mysql_num_rows($thisRow) < 1)" it does what I want. I guess if I want to understand why False was returned originally (just after I created the database) I need to start over. According to the docs mysql_query only returns false if there's an error. Do I have 4 possible conditions here: 1) the mysql_query() function fails and I get a PHP error, 2) the query fails at the server and I get False, or 3) the query doesn't fail at the server and I get "a result" that a) is empty, or b) contains 1 or more rows? Yes. 1) I'm not sure what you mean. If you try to run a query before having a connection (or not checking the connection is valid before running a query), then mysql_query will return false and php will throw warnings or notices (can't remember which). 2) Correct 3) Also correct. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Need help-Send email
What _IS_ required is a valid recipient. What google requires to send an email through their servers is smtp authentication - none was mentioned in the original post (nor any follow up suggestions). If the recipient is invalid, it will bounce back - just like any other email where you mis-spell a name or any of the other problems that can happen. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_query returning empty result after DELETE
OK. If I change the test to "if(mysql_num_rows($thisRow) < 1)" it does what I want. I guess if I want to understand why False was returned originally (just after I created the database) I need to start over. Do I have 4 possible conditions here: 1) the mysql_query() function fails and I get a PHP error, 2) the query fails at the server and I get False, or 3) the query doesn't fail at the server and I get "a result" that a) is empty, or b) contains 1 or more rows? Yes. Problem solved (my code was naive), understanding increased (my code won't be naive in the future as regards mysql functions in PHP). Thank you very much.. "Chris" wrote in message news:4aad74e5.3090...@gmail.com... > Stan wrote: > > I did a "DELETE FROM picture" where "picture" is a table in my database. > > Because this deletes all your records - so doing a select afterwards > will find nothing. > > > Afterward, this piece of code does not generate an error > > -- > > try > > { > > $query = "SELECT * FROM picture p " . > > "WHERE p.pictureFile='" . $pictureFile . "'"; > > $thisRow = > > mysql_query($query, $pictures_connection); > > } > > catch(Exception $e) > > { > > echo 'caught exception: ', $e->getMessage()."\n"; > > $result = False; > > } > > an empty result set is fine - it means no records found. It will not > generate an exception. > > I'm not sure when mysql will generate an exception either, mysql_query > returns FALSE if the query fails (see http://www.php.net/mysql_query). > You then have to use mysql_error to get the reason why it failed. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_query returning empty result after DELETE
Yes. I deleted all records. Prior to the DELETE, if I did a SELECT with specific criteria (WHERE p.pictureFile = "some valid content"), and those criteria were not met, mysql_query() returned False ... and, conversely, if those criteria were met, mysql_query() returned "a resource" against which I could use mysql_fetch() to retrieve the rows returned by the SELECT. After the DELETE, and as I explained in my original post, the same SELECT with specific criteria returns, not False as it should, but "a resource" which contains an empty row. If I look at the database using MySQL Query Browser, it appears empty. I do not understand what is happening. Help understanding what is happening is what I seek. Can you help? Thanks. "Chris" wrote in message news:4aad74e5.3090...@gmail.com... > Stan wrote: > > I did a "DELETE FROM picture" where "picture" is a table in my database. > > Because this deletes all your records - so doing a select afterwards > will find nothing. > > > Afterward, this piece of code does not generate an error > > -- > > try > > { > > $query = "SELECT * FROM picture p " . > > "WHERE p.pictureFile='" . $pictureFile . "'"; > > $thisRow = > > mysql_query($query, $pictures_connection); > > } > > catch(Exception $e) > > { > > echo 'caught exception: ', $e->getMessage()."\n"; > > $result = False; > > } > > an empty result set is fine - it means no records found. It will not > generate an exception. > > I'm not sure when mysql will generate an exception either, mysql_query > returns FALSE if the query fails (see http://www.php.net/mysql_query). > You then have to use mysql_error to get the reason why it failed. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Need help-Send email
2009/9/14 Chris : > nagendra prasad wrote: >> >> Hi all, >> >> Below is the code that I have coded after replies from all of you. But >> before that I want to thank all of you for your help. I have coded the >> email >> code but still it is giving me an error. Please help me. > > ... and the error is what exactly? > >> > >> //sending email script >> >> $to = "exam...@gmail.com"; >> $subject = "Email from admin"; >> >> if ($_POST['submit']) >> { >> //get data from form >> >> $name = $_POST['name']; >> $message = $_POST['message']; >> if ($name&&$message) >> { >> $namelen = 20; >> $messagelen = 300; >> if (strlen($name)<=$namelen && strlen($message)<=$messagelen) >> { >> //everything is ok >> >> ini_set("SMTP", "smtp.gmail.com"); > > Where's your smtp authentication? You can't just set the mail server and > that's it. > > http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html > > Use phpmailer (as this article suggests) and you'll have a lot better chance > of things working. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Follow these steps... 1 - What is the domain of the recipient? gmail.com 2 - What is recipients SMTP server? nslookup -q=mx gmail.com [2009/09/14 10:10:58] [C:\] [] >nslookup -q=mx gmail.com Server: bv-vm-svr-1.bandvulc.local Address: 10.0.30.1 Non-authoritative answer: gmail.com MX preference = 40, mail exchanger = alt4.gmail-smtp-in.l.google.com gmail.com MX preference = 10, mail exchanger = alt1.gmail-smtp-in.l.google.com gmail.com MX preference = 5, mail exchanger = gmail-smtp-in.l.google.com gmail.com MX preference = 30, mail exchanger = alt3.gmail-smtp-in.l.google.com gmail.com MX preference = 20, mail exchanger = alt2.gmail-smtp-in.l.google.com alt4.gmail-smtp-in.l.google.com internet address = 72.14.247.27 alt1.gmail-smtp-in.l.google.com internet address = 209.85.129.114 gmail-smtp-in.l.google.com internet address = 74.125.79.114 alt3.gmail-smtp-in.l.google.com internet address = 209.85.223.14 alt2.gmail-smtp-in.l.google.com internet address = 209.85.218.33 Use one of the servers you see here. These are the public SMTP servers set to RECEIVE email from anyone. No authority required. What _IS_ required is a valid recipient. The output of the nslookup command can also be seen by using getmxrr() in PHP. Look at the user notes on http://docs.php.net/getmxrr for versions of getmxrr() for versions of PHP on windows which didn't have this function. At a fundamental level, this is how email is sent. You normally send it to a server you are allowed to send to (a relay). This normally requires some sort of security (not always - but may require you to POP3 login to your mailbox). You send the mail. The local server receives it. By using the domain of the recipient the server finds where to send it. The recipients server knows nothing about YOUR server - no authority - but has to accept the message. Using getmxrr() is bypassing the local relay step and going direct. Obviously, you have to handle all the errors, retries, etc. But you can also step through the servers if one is offline or whaterver. -- - Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php