rawky1976 Posted August 31, 2007 Share Posted August 31, 2007 Hello I'm having trouble with single and double quote nesting; i know this is wrong, but why? $query = "SELECT CONCAT(client_lname, ', ',client_fname) AS name FROM clients ASC WHERE client_lname = $_POST['editclient']"; Quote Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/ Share on other sites More sharing options...
teng84 Posted August 31, 2007 Share Posted August 31, 2007 maybe $query = "SELECT CONCAT(client_lname, ', ',client_fname) AS name FROM clients ASC WHERE client_lname = ".$_POST['editclient']; or $query = "SELECT CONCAT(client_lname, ', ',client_fname) AS name FROM clients ASC WHERE client_lname = '".$_POST['editclient']."'"; or $query = "SELECT CONCAT(client_lname, ', ',client_fname) AS name FROM clients ASC WHERE client_lname = {$_POST['editclient']}"; Quote Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/#findComment-338961 Share on other sites More sharing options...
Fadion Posted August 31, 2007 Share Posted August 31, 2007 $query = "SELECT CONCAT(client_lname, ', ',client_fname) AS name FROM clients ASC WHERE client_lname = '{$_POST['editclient']}'"; Quote Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/#findComment-338964 Share on other sites More sharing options...
rawky1976 Posted August 31, 2007 Author Share Posted August 31, 2007 Notice: Undefined index: editclient in C:\inetpub\wwwroot\***\***.php on line 53 This refers to the $editclient variable since I changed to the above? Quote Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/#findComment-338976 Share on other sites More sharing options...
lemmin Posted August 31, 2007 Share Posted August 31, 2007 That means that there is no key inside the array $_POST named "editclient". To see the keys, do a "print_r($_POST)" and the keys are the ones in square brackets. Quote Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/#findComment-338981 Share on other sites More sharing options...
rawky1976 Posted August 31, 2007 Author Share Posted August 31, 2007 what if editclient is just a text input in a form, not an array. Would that change things? Quote Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/#findComment-338986 Share on other sites More sharing options...
Fadion Posted September 1, 2007 Share Posted September 1, 2007 $_POST is actually an array and 'editclient' is an array key or index. The code should work like that so be sure to have a textfield called 'editclient'. Anyway try this different approach but should give the same results: $editclient = $_POST['editclient']; $query = "SELECT CONCAT(client_lname, ', ',client_fname) AS name FROM clients ASC WHERE client_lname='$editclient'"; Quote Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/#findComment-339013 Share on other sites More sharing options...
rawky1976 Posted September 1, 2007 Author Share Posted September 1, 2007 Hello again, found the problem with the above; I named the submit button instead of the text field in the form!!! Sorry guys! What can I put between these two lines to display the content of $query on the webpage? It's now dropping out of the if condition to display 'no results match etc...' $result = @mysql_query ($query); if ($result) { ? Thanks, Mark Quote Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/#findComment-339446 Share on other sites More sharing options...
darkfreaks Posted September 1, 2007 Share Posted September 1, 2007 <?php result = @mysql_query ($query); if ($result) { echo($result);} Quote Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/#findComment-339457 Share on other sites More sharing options...
rawky1976 Posted September 1, 2007 Author Share Posted September 1, 2007 thanks, seems to be the 'ASC' causing problems, removed that and I get results! Quote Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/#findComment-339463 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.