Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
by jocana » Wed Oct 10, 2012 6:15 pm
Hi, I'm trying to make a website but before I actually start it, I played around with php for a little bit. I know a little about coding from research I've done myself, but for some reason my code keeps getting a syntax error and I do not know why. Could anyone please help me?
- Code: Select all
<?php
mysql_connect("localhost","root","password") or die("could not connect");
mysql_select_db("gamerz_ultd") or die("could not connect to db");
$output = '';
//collect
if(isset($POST['search'])) {
$searchq = $_POST['search'];
$query = mysql_quert("SELECT * FROM sign_up") or die ("could not search");
$count = mysql_numb_rows($query);
if($count == 0){
$output = 'There was no search results';
}else{
while($row = mysql_fetch_array($query)) {
$fname = $row['user_first_name'];
$lname = $row['user_last_name'];
$id = $row['id'];
$output .= '<div> '.$fname.' '.lname.'</div>';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Search</title>
</head>
<body>
<form action="index.php" method="post">
<input type="text" name="search" placeholder="search">
<input type="submit" value=">>">
</form>
</body>
</html>
-
jocana
- New php-forum User

-
- Posts: 4
- Joined: Tue Oct 09, 2012 9:21 pm
by MeroD » Wed Oct 10, 2012 11:02 pm
$query = mysql_query("SELECT * FROM sign_up");
$count = mysql_num_rows($query);
-
MeroD
- New php-forum User

-
- Posts: 53
- Joined: Wed Oct 10, 2012 12:14 am
by jocana » Fri Oct 12, 2012 7:22 am
Wow, I can't believe I didn't catch that, thank you! by the way would you also know why my website elements change when I log on to it? I am completely confused.
-
jocana
- New php-forum User

-
- Posts: 4
- Joined: Tue Oct 09, 2012 9:21 pm
Return to PHP coding => General
Who is online
Users browsing this forum: No registered users and 3 guests