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']"; 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']}"; 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']}'"; 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? 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. 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? 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'"; 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 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);} 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! Link to comment https://forums.phpfreaks.com/topic/67508-solved-escaping-singledouble/#findComment-339463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.