Hi,
I have a problem in PHP about Query of concating.
Please, guide me
1: test.sql is dump file
-- PHP Version: 4.4.2
--
-- Database: `pradeep`
--
-- --------------------------------------------------------
--
-- Table structure for table `test`
--
CREATE TABLE `test` (
`id` int(11) NOT NULL,
`fullname` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `test`
--
INSERT INTO `test` (`id`, `fullname`) VALUES (1, 'ankur patil'),
(2, 'avinash chaudhary'),
(3, 'raju za'),
(4, 'tanmay wagh');
2:bkslash.html
<html>
<body>
<form action=bkslash2 .php method=post>
<input type="text" name="input1">
<select name=fields>
<option value='id'>id</option>
<option value=concat(co ncat(Fullname,' ,'),id)>Fullnam e & Id</option>
</select>
<input type=submit >
</form>
</body>
</html>
3:bkslash2.php
<?php
mysql_connect(" localhost","pro ex")or die("Database Failed");
mysql_select_db ("pradeep")o r die("Failed to Connect Database");
$str="select fullname from test where ".$_REQUEST['fields']." like '%".
$_REQUEST['input1']."%'";
echo $str;
$res=mysql_quer y($str) or die("resultset error");
$row=mysql_fetc h_row($res);
echo "<br>result<hr> ";
print_r($row);
?>
here, in output, if i enter any value (let 3) in text box & in combo
box
select Fullname & id then it gives me resultant error
& Query becomes
select fullname from test where concat(concat(F ullname,\',\'), id) like
'%3%'
so, how i get right output ?
Please, guide me.
I have a problem in PHP about Query of concating.
Please, guide me
1: test.sql is dump file
-- PHP Version: 4.4.2
--
-- Database: `pradeep`
--
-- --------------------------------------------------------
--
-- Table structure for table `test`
--
CREATE TABLE `test` (
`id` int(11) NOT NULL,
`fullname` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `test`
--
INSERT INTO `test` (`id`, `fullname`) VALUES (1, 'ankur patil'),
(2, 'avinash chaudhary'),
(3, 'raju za'),
(4, 'tanmay wagh');
2:bkslash.html
<html>
<body>
<form action=bkslash2 .php method=post>
<input type="text" name="input1">
<select name=fields>
<option value='id'>id</option>
<option value=concat(co ncat(Fullname,' ,'),id)>Fullnam e & Id</option>
</select>
<input type=submit >
</form>
</body>
</html>
3:bkslash2.php
<?php
mysql_connect(" localhost","pro ex")or die("Database Failed");
mysql_select_db ("pradeep")o r die("Failed to Connect Database");
$str="select fullname from test where ".$_REQUEST['fields']." like '%".
$_REQUEST['input1']."%'";
echo $str;
$res=mysql_quer y($str) or die("resultset error");
$row=mysql_fetc h_row($res);
echo "<br>result<hr> ";
print_r($row);
?>
here, in output, if i enter any value (let 3) in text box & in combo
box
select Fullname & id then it gives me resultant error
& Query becomes
select fullname from test where concat(concat(F ullname,\',\'), id) like
'%3%'
so, how i get right output ?
Please, guide me.
Comment