Re: [PHP-DB] Newbie Question $2
Can we kill this thread? Or can you guys continue the conversation between yourselves. We now have 8 emails pertaining to the technical question, and 8 emails ranting about him asking it. I understand that some people do not believe this is the appropriate forum for that question - but personal attacks and rantings accomplish nothing other than to provide bully tactics and express your outrage at list spamming while spamming the list. Thank you for your consideration. - Mike On Wed, Jun 18, 2014 at 11:49 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 6/18/2014 2:16 PM, Aziz Saleh wrote: On Wed, Jun 18, 2014 at 2:13 PM, Karl DeSaulniers k...@designdrumm.com wrote: Sent from losPhone On Jun 18, 2014, at 7:56 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 6/18/2014 12:31 AM, Ethan Rosenberg, PhD wrote: On 06/17/2014 12:02 PM, onatawah...@yahoo.ca wrote: Hi Ethan, Here are some things to clean up your code: Your line: $phn = $_POST[phone]; should use quotations as follows: $phn = $_POST['phone']; Your line: $sql1 ='select Lname, Fname from Customers where Phone = $Phn '; Should use double quotes if you need the variable to be interpreted: $sql1 =select Lname, Fname from Customers where Phone = $Phn ; Lastly, as people have mentioned PDO is probably the best way to go. Try connecting to your database with PDO. Look on Google for PDO prepared statements and use those instead of the mysql escape string method. Hope this helps, -Kevin Sent from Yahoo Mail on Android IT WORKS!!! Here is the code - !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; html ?php $bla = 1; ? head /head body div align=center form method=post input type='text' name=phone/input input type='submit' br /br /br / /form /div ?php error_reporting(-1); require '/home/ethan/PHP/ethan.inc'; $db = Store; $cxn = mysqli_connect($host,$user,$password,$db); $phn = $_POST[phone]; $phn = (string)$phn; $dsh = '-'; $Phn = $phn[0].$phn[1].$phn[2].$dsh.$phn[3].$phn[4].$phn[5].$dsh.$ phn[6].$phn[7].$phn[8].$phn[9]; $sql1 =select Lname, Fname from Customers where Phone = '$Phn' ; $result1 = mysqli_query($cxn, $sql1); if(!$result) { ? div align=center strongNo Match Found/strong br /br / /div ?php } ? div align=center table border=4 cellpadding=5 cellspacing=55 rules=all frame=box tr class='heading' thLast Name/th thFirst Name/th ?php while($row1 = mysqli_fetch_row($result1)) { $Lname = $row1[0]; $Fname = $row1[1]; ? tr td ?php echo $Lname; ? /td td ?php echo $Fname; ? /td /tr ?php } ? /table /div /body /html As you [those that replied] accurately noted, the problem was with the quoting. I appreciate all your comments, take them seriously and will use the information contained in them for future programming. No matter how much skill in programming I have, I will remain a NEWBIE; ie, someone who wishes to grrow in knowledge and acknowledges that there are many programmers much more skilled than I. Thanks again. Ethan happy to hear you got it working. Sad to see that you didn't heed the tips provided to you and alter your code, and that you still have errors in it. oh, well Wow. Just wow. I though when I signed up on this list that if I did what Ethan did I would be shunned from the list. But I guess I was wrong. You can be an ask hole on here and people will still try and help. Kudos to the good souls who try. Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php There are lots of people who have free time on their hands to teach the basics, which I think is a good thing. Personally, if someone doesn't care enough to read the manual or attempt to understand the basics, I wouldn't spend too much time on their problems. And despite Ethan's continual ignorance of the manual and the basic principles espoused by those taking the time to respond to him we still do it. Aren't we all amazing? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- --- My command is this: Love each other as I have loved you. John 15:12
Re: [PHP-DB] Subject Matter
*There are a lot of off topic emails sent. But there is far more whining and **complaining. Good grief! +1* Let's remember that not everyone on the list is an expert programmer or someone with years of DBA experience. The purpose of the list (IMHO) is to HELP others with their PHP/DB questions, or at least point them in the right direction so that they can continue to learn and grow. This is one thing I have commended the PHP community for, their willingness to INCLUDE people and be patient with newbies. Sure there are going to be off-topic conversations, questions that get proposed to the wrong list, etc - heck I'm guilty of it myself. But quite frankly (haven't had my coffee, be warned), if you're going to complain that not every message on the list meets your specific standards, then you're in the wrong place. Add some filters to your mailbox, or better yet, jump in and help out instead of complaining that your needs aren't being met. Just my two cents... - Mike ps - if you look on php.net it clearly says this list is NOT moderated... On Mon, Aug 26, 2013 at 9:32 AM, Thomas Rudy thomasbr...@gmail.com wrote: There are a lot of off topic emails sent. But there is far more whining and complaining. Good grief! On Fri, Aug 23, 2013 at 2:40 PM, Tamara Temple tamouse.li...@gmail.com wrote: On Aug 23, 2013, at 7:32 AM, Jim Giner jim.gi...@albanyhandball.com wrote: On 8/23/2013 4:52 AM, Matt Pelmear wrote: On 08/23/2013 04:36 PM, Lester Caine wrote: Matt Pelmear wrote: I am not sure who runs the list, whether they care about off-topic posts, or whether anyone else cares about it. The php lists are only loosely moderated, but comments like yours usually bring things under control. I'd refer you to my recent post thought as to why the current threads are not that far off topic ;) Indeed, that thread is one that is on topic... but I think the signal-to-noise ratio on this list is rather poor ;) If I'm the only one bothered by it, it's no big deal for me to unsubscribe... I just thought I'd check the general opinion first. I don't run into these problems on the internals list... :-) -Matt Funny - I never knew this list was handling off-topic posts that regularly. I always thought this list was about using php to access database info and the problems incurred, such as Ethan's recent post about his bad query code. So - this is supposed to be about database integration? I'll have to reconsider my subscription choice as well, just as soon as I look up whatever the heck that is. :) This is the description on www.php.net/mailing-lists.php: Databases and PHP This list is for the discussion of PHP database topics Nothing more specific than that. I, personally, don't know of any PHP databases, so I'm going to assume it means the broader interpretation of using PHP with databases. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- --- My command is this: Love each other as I have loved you. John 15:12 ---
Re: [PHP-DB] PDO user question
How are you using the number? Probably the easiest way is to utilize PDOStatement::FetchAll() and then do a count() on that result set. - Mike Sent from my iPhone On Sep 9, 2012, at 11:42 AM, Stefan Wixfort stefan.wixf...@gmx.de wrote: Hi Jim I've had some success with querying using pdo and prepared statements as well. One thing that I'm curious about is How does one handle the need to get the number of rows returned by a Select? The documentation is very clear that PDO doesn't return that value for a Select statement (depending upon driver?) and there were a couple of solutions that made no sense to me. There was even one that did a completely separate query just to get the row count which makes even less sense. I believe you are referring to SELECT COUNT(*)... Because I couldn't find a different way I use that. -- 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
Re: [PHP-DB] Help with If else if
From looking at your code, the issue is that your if statements are checking for the same criteria as your else statements, meaning that if the string is empty () the if statements will be triggered, and since the if statements are true, the elseif statement will not be. Or if the string isn't empty, neither the if or the elseif statements will be triggered, causing the else statement to be activated. Either way, the images would be printed out. * * * * *Did you mean to do this?* ?php if($search-plugin-ListViewValue() == $search-facebook-ListViewValue() == ) { // Neither one has a value } elseif ($search-plugin-ListViewValue() != $search-facebook-ListViewValue() != ) { // Both have a Value echo 'a href=' . $search-plugin-ListViewValue() . 'img src=images/twitter.gif width=22 height=23//a/a' . 'a href=' . $search-facebook-ListViewValue() . 'img src=images/facebook.gif width=22 height=23//a/a'; } elseif ($search-plugin-ListViewValue() != ) { // Twitter has a value echo 'a href=' . $search-plugin-ListViewValue() . 'img src=images/twitter.gif width=22 height=23//a/a'; } else { // Facebook has a value (only possible option left) echo 'a href=' . $search-facebook-ListViewValue() . 'img src=images/facebook.gif width=22 height=23//a/a'; } ? Hope that helps, Mike On Tue, Mar 13, 2012 at 9:44 AM, Matijn Woudt tijn...@gmail.com wrote: On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com wrote: The issue is both the images are echoing and no if else statement is working. First of all, please bottom post on this (and probably any) mailing list. You should perhaps provide what the contents of $search-plugin-ListViewValue()== and $search-facebook-ListViewValue()== is. Though, if I understood you correctly, it would be as simple as: $facebookEnabled = $search-facebook-ListViewValue()!=; $twitterEnabled = $search-plugin-ListViewValue()!=; if($facebookEnabled) { echo 'a href='.$search-facebook-ListViewValue().'img src=images/facebook.gif width=22 height=23//a/a'; } if($twitterEnabled) { echo 'a href='.$search-plugin-ListViewValue().'img src=images/twitter.gif width=22 height=23//a/a'; } - Matijn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- --- My command is this: Love each other as I have loved you. John 15:12 ---
Re: [PHP-DB] Help with If else if
Hmm, what happens with the code I sent you? Just tested it on my end and worked exactly as expected. Try doing a var_dump($search-plugin-ListViewValue(), $search-facebook-ListViewValue()); to make sure the data being returned is what's expected... you should be getting string(0) returned for both. Thanks, Mike On Tue, Mar 13, 2012 at 10:53 AM, Gu®u nagendra802...@gmail.com wrote: No Michael, your code is also not working. What you have understood is correct. let me explain it to others too. If variable twitter and facebook are empty don't echo anything, if variable twitter has a value and facebook is empty echo out only twitter, if variable twitter has no value and facebook has a value echo out facebook only, and finally if both has values echo out both. Basically I want to echo out only if there is some value in the database. But in my case both the images are echoing out. On Tue, Mar 13, 2012 at 8:54 PM, Michael Stowe m...@mikestowe.com wrote: From looking at your code, the issue is that your if statements are checking for the same criteria as your else statements, meaning that if the string is empty () the if statements will be triggered, and since the if statements are true, the elseif statement will not be. Or if the string isn't empty, neither the if or the elseif statements will be triggered, causing the else statement to be activated. Either way, the images would be printed out. * * * * *Did you mean to do this?* ?php if($search-plugin-ListViewValue() == $search-facebook-ListViewValue() == ) { // Neither one has a value } elseif ($search-plugin-ListViewValue() != $search-facebook-ListViewValue() != ) { // Both have a Value echo 'a href=' . $search-plugin-ListViewValue() . 'img src=images/twitter.gif width=22 height=23//a/a' . 'a href=' . $search-facebook-ListViewValue() . 'img src=images/facebook.gif width=22 height=23//a/a'; } elseif ($search-plugin-ListViewValue() != ) { // Twitter has a value echo 'a href=' . $search-plugin-ListViewValue() . 'img src=images/twitter.gif width=22 height=23//a/a'; } else { // Facebook has a value (only possible option left) echo 'a href=' . $search-facebook-ListViewValue() . 'img src=images/facebook.gif width=22 height=23//a/a'; } ? Hope that helps, Mike On Tue, Mar 13, 2012 at 9:44 AM, Matijn Woudt tijn...@gmail.com wrote: On Tue, Mar 13, 2012 at 3:06 PM, Gu®u nagendra802...@gmail.com wrote: The issue is both the images are echoing and no if else statement is working. First of all, please bottom post on this (and probably any) mailing list. You should perhaps provide what the contents of $search-plugin-ListViewValue()== and $search-facebook-ListViewValue()== is. Though, if I understood you correctly, it would be as simple as: $facebookEnabled = $search-facebook-ListViewValue()!=; $twitterEnabled = $search-plugin-ListViewValue()!=; if($facebookEnabled) { echo 'a href='.$search-facebook-ListViewValue().'img src=images/facebook.gif width=22 height=23//a/a'; } if($twitterEnabled) { echo 'a href='.$search-plugin-ListViewValue().'img src=images/twitter.gif width=22 height=23//a/a'; } - Matijn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- --- My command is this: Love each other as I have loved you. John 15:12 --- -- *Best, * *Gu®u* -- --- My command is this: Love each other as I have loved you. John 15:12 ---