Jump to content

PHP MySQL problem


madsovenielsen

Recommended Posts

I have this PHP and SQL

<?php$conn = mysql_connect('localhost', 'root', '**********');mysql_select_db("bookmarks", $conn);?><html>	<head>		<title>Bookmark app</title>	</head>	<body>		<h1>Bookmark App</h1>		<form action="<?php echo $PHP_SELF;?>" method="post">			Search <input name="strSearch" type="text" /> <input type="submit" name="submit" />		</form>	<?php 		if(isset($_POST['submit'])){ 			$sql = "SELECT * FROM bookmarks WHERE url LIKE " . "'" . $_POST["strSearch"] . "'";			echo $sql;		$res= mysql_query($sql);		while($row = mysql_fetch_assoc($res)) 		{			$row["url"];		}		} 	  ?>	</body></html>

When i type something in the search field and submit i dont get the expected result. it shouldt display the rows from the DB thats like the search string from the search field input.The DB and everything is working fine. so thats not the problem. its in the code somewhere.Whats wrong with this PHP and/or SQL ?/mads

Link to comment
Share on other sites

That's not going to do a wildcard search, that's only going to find records where the URL is exactly what you typed in. If you want to search for something in the URL, you need to use the wildcard character in the string.http://dev.mysql.com/doc/refman/5.0/en/str...-functions.html
Thanks. but if i search for the exact same url thats in the DB, i dont get any result ?/mads
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...