Hiya folks!
So, I’m creating a search for my website, using Mysql_Query to find the user my ‘searcher’ was looking for, so, I kind of ran in to a problem. My code runs and, will alway’s, print ‘Resource ID #4’, cause that’s apparently what my mysql_query would like to ‘echo’. Anyway’s, what would happen is, when it reads the variable from the top of my url (Using PHP Arguments), it’s using mysql_query to search from my database for the name. If it finds the name, it’s suppose to echo, ‘found him!’, if not then echo, ‘didnt find him!’. Code is shown below.
<!DOCTYPE html>
<html>
<head>
<link REL=StyleSheet HREF="MainCSS.css" TYPE="text/css" MEDIA=screen>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
[php]
<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$name=$_REQUEST['name'];
$fetch=mysql_query("SELECT * FROM users.userdata WHERE username='$name'");
if (!$fetch) {
die('Invalid query: ' . mysql_error());
}
if ($fetch==0) {
echo 'Didnt find the user';
}
mysql_close($link);
?>
[/php]
</body>
</html>
Another question I have, is how do I escape the 's? So I can echo “don’t”, and stuff?