Jump to content

prakash911

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

prakash911's Achievements

Member

Member (2/5)

0

Reputation

  1. please i really need this to work, cant anyone spot the problem.
  2. my code works perfect, but the only problem is after submit the output page is displayed underneath the main page, i want it to be redirected into a new web page instead of underneath it how do i do this. here is my code i think the problem is how i setted up my if statements can someone tell me where i went wrong? <?php require('db_connect.php'); $database = "chennupatidb"; $db_link = db_connect($database); ?> <?php function display_signup_page() { $self = $_SERVER['PHP_SELF']; ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <link href="books.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Sign Up</title> <script type="text/javascript"> function validate(table) { if (!document.table.agree.checked){ alert("Please Read the guidlines and check the box below ."); return false; } return true; } </script> <style type="text/css"> .style1 { font-size: medium; } .style2 { margin-left: 240px; } </style> </head> <body> <div id="pageWrap"> <div id="header"> </div> <div id="navBar"> <ul> <li><a href="Bookstore.php" title="Homw">Home</a></li> <li><a href="search.php" title="Search">Search</a></li> <li><a href="forum.php" title="Forum">Forums</a></li> <li><a href="login.php" title="Contact">Login</a></li> <li class="end"> <a href="signup.php" title="signup">Sign Up</a></li> <li></li> </ul> </div> <div id="container" class="clearfix"> <div id="centerColumn"> <h2>Create an Account</h2> <p><font size="-1">If you already have a SC Bookstore Account, you can <a href="login.html"> login in here</a>.</font></p> <p class="style1"><strong>Required information</strong></p> <table border='0' width='50%' cellspacing='0' cellpadding='0' align="center"> <form method="post" action="<?php echo $self ?>" onsubmit='return validate(this)'> <input type="hidden" name="table" value="post"> <tr bgcolor='#f1f1f1'><td align="center" colspan=2><font face='Verdana' size='2' ><b>Signup</b></font></td></tr> <tr ><td > <font face='Verdana' size='2' >User ID</font></td><td ><font face='Verdana' size='2'></font><input type="text" name="userid"></td></tr> <tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Password</font></td><td ><font face='Verdana' size='2'><input type='password' name="password"></font></td></tr> <tr ><td > <font face='Verdana' size='2' >Re-enter Password</font></td><td ><font face='Verdana' size='2'><input type='password' name="password2"></font></td></tr> <tr bgcolor='#f1f1f1'><td style="height: 21px" ><font face='Verdana' size='2' > Email<br> (abcd123@hotmail.com)</font></td><td style="height: 21px" ><input type='text' name='email'></td></tr> <tr ><td > <font face='Verdana' size='2' >First Name</font></td><td ><font face='Verdana' size='2'><input type="text" name="firstname"></font></td></tr> <tr ><td > <font face='Verdana' size='2' >Last Name</font></td><td ><font face='Verdana' size='2'><input type="text" name="lastname"></font></td></tr> <tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Sex</font></td><td ><font face='Verdana' size='2'> <input type='radio' value="male" checked="checked" name="sex">Male <input type='radio' value="female" name='sex'>Female</font></td></tr> <tr ><td > <font face='Verdana' size='2' >I agree to terms and conditions</font></td> <td > Yes<input name="agree" type="checkbox" value="yes">No<input name="agree" type="checkbox" value="no"></td></tr> <p class="style2"> <input name="signup" type="submit" value="signup"></p> </form> </table> </div> </div> <div id="footer"> <p> SC Books • Est.2010</p> </div> </div> </body> </html> <?php } ?> <?php function display_signup_output_page() { ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <link href="books.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>SC BookStore</title> </head> <body> <div id="pageWrap"> <div id="header"> </div> <div id="navBar"> <ul> <li><a href="Bookstore.php" title="Homw">Home</a></li> <li><a href="search.php" title="Search">Search</a></li> <li class="end"><a href="forum.php" title="Forum">Forums</a></li> <li></li> </ul> </div> <div id="container" class="clearfix"> <div id="centerColumn"> <h2> Thank You For Signing Up!</h2> <p> </p> <h3>You Can Login here </h3><p><a href="login.php">Click here to login</p> </div> </div> </div> </body> </html> <?php } ?> <?php extract($_POST); $self = $_SERVER['PHP_SELF']; $user_id = isset($_REQUEST['userid']) ? $_REQUEST['userid'] : ''; $first_name = isset($_REQUEST['firstname']) ? $_REQUEST['firstname'] : ''; $last_name = isset($_REQUEST['lastname']) ? $_REQUEST['lastname'] : ''; $password_one = isset($_REQUEST['password']) ? $_REQUEST['password'] : ''; $password_two = isset($_REQUEST['password2']) ? $_REQUEST['password2'] : ''; $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : ''; $agree = isset($_REQUEST['agree']) ? $_REQUEST['agree'] : ''; $signup = isset($_REQUEST['signup']) ? $_REQUEST['signup'] : ''; $table = isset($_REQUEST['table']) ? $_REQUEST['table'] : ''; display_signup_page(); if (isset($_REQUEST['signup'])) { $expression = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/"; $errors = 0; if(!isset($user_id) or strlen($user_id) < 5) { echo "<br/>\nUser ID must be 5 letters or longer<br/>\n"; $errors++; } if(!ctype_alnum($user_id)) { echo "<br/>\nUser id should contain alphanumeric values only<br/>\n"; $errors++; } if(mysql_num_rows(mysql_query("SELECT userid FROM sign_up WHERE userid = '$userid'"))) { echo "<br/>\nThis User ID already exists. Please try another one<br/>\n"; $errors++; } if (strlen($password_one) < 6 ) { echo "<br/>\nPassword must be more than 6 char legth<br/>\n"; $errors++; } if ($password_one <> $password_two) { echo "<br/>\nPasswords are not matching<br/>\n"; $errors++; } if(strlen($email) == 0) { echo "Please go back and check (ex:abcd123@hotmail.com)<br/>\n"; $errors++; } if (! $agree == "yes") { echo "<br/>\nYou must agree to terms and conditions<br\>\n"; $errors++; } if($errors >= 1) { echo "<br/>\n<input type='button' value='Retry' onClick='history.go(-1)'>\n"; } else { display_signup_output_page(); $query = "insert into sign_up(userid,password,email,firstname,lastname,sex) values('$userid','$password','$email','$firstname','$lastname','$sex')"; $result = mysql_query($query,$db_link); $query2 = "insert into members(username,password,email) values('$userid','$password','$email')"; $result2 = mysql_query($query2,$db_link); echo "<br/><h1>Welcome,\n You have successfully signed up\n</h1><br/><br/>\n<a href=login.php>Click here to login</a><br/>\n"; } } ?> here is a picture of what i am getting, i dont want this.
  3. i cant seem to figure out why, but nothing is happening when i click the button to submit the signup form. can you guys tell me what the problem is. <?php require('db_connect.php'); $database = "chennupatidb"; $db_link = db_connect($database); display_signup_page(); ?> <?php function display_signup_page() { $self = $_SERVER['PHP_SELF']; ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <link href="books.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Sign Up</title> <script type="text/javascript"> function validate(table) { if (!document.table.agree.checked){ alert("Please Read the guidlines and check the box below ."); return false; } return true; } </script> <style type="text/css"> .style1 { font-size: medium; } .style2 { margin-left: 240px; } </style> </head> <body> <div id="pageWrap"> <div id="header"> </div> <div id="navBar"> <ul> <li><a href="Bookstore.php" title="Homw">Home</a></li> <li><a href="search.php" title="Search">Search</a></li> <li><a href="forum.php" title="Forum">Forums</a></li> <li><a href="login.php" title="Contact">Login</a></li> <li class="end"> <a href="signup.php" title="signup">Sign Up</a></li> <li></li> </ul> </div> <div id="container" class="clearfix"> <div id="centerColumn"> <h2>Create an Account</h2> <p><font size="-1">If you already have a SC Bookstore Account, you can <a href="login.html"> login in here</a>.</font></p> <p class="style1"><strong>Required information</strong></p> <table border='0' width='50%' cellspacing='0' cellpadding='0' align="center"> <form method="post" action="<?php echo $self ?>" onsubmit='return validate(this)'> <input type="hidden" name="table" value="post"> <tr bgcolor='#f1f1f1'><td align="center" colspan=2><font face='Verdana' size='2' ><b>Signup</b></font></td></tr> <tr ><td > <font face='Verdana' size='2' >User ID</font></td><td ><font face='Verdana' size='2'></font><input type="text" name="userid"></td></tr> <tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Password</font></td><td ><font face='Verdana' size='2'><input type='password' name="password"></font></td></tr> <tr ><td > <font face='Verdana' size='2' >Re-enter Password</font></td><td ><font face='Verdana' size='2'><input type='password' name="password2"></font></td></tr> <tr bgcolor='#f1f1f1'><td style="height: 21px" ><font face='Verdana' size='2' > Email<br> (abcd123@hotmail.com)</font></td><td style="height: 21px" ><input type='text' name='email'></td></tr> <tr ><td > <font face='Verdana' size='2' >First Name</font></td><td ><font face='Verdana' size='2'><input type="text" name="firstname"></font></td></tr> <tr ><td > <font face='Verdana' size='2' >Last Name</font></td><td ><font face='Verdana' size='2'><input type="text" name="lastname"></font></td></tr> <tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Sex</font></td><td ><font face='Verdana' size='2'> <input type='radio' value="male" checked="checked" name="sex">Male <input type='radio' value="female" name='sex'>Female</font></td></tr> <tr ><td > <font face='Verdana' size='2' >I agree to terms and conditions</font></td> <td > Yes<input name="agree" type="checkbox" value="yes">No<input name="agree" type="checkbox" value="no"></td></tr> </form> </table> <p class="style2"> <input name="signup" type="submit" value="signup"></p> </div> </div> <div id="footer"> <p> SC Books • Est.2010</p> </div> </div> </body> </html> <?php } ?> <?php function display_signup_output_page() { ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <link href="books.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>SC BookStore</title> </head> <body> <div id="pageWrap"> <div id="header"> </div> <div id="navBar"> <ul> <li><a href="Bookstore.php" title="Homw">Home</a></li> <li><a href="search.php" title="Search">Search</a></li> <li class="end"><a href="forum.php" title="Forum">Forums</a></li> <li></li> </ul> </div> <div id="container" class="clearfix"> <div id="centerColumn"> <h2> Thank You For Signing Up!</h2> <p> </p> <h3>You Can Login here </h3><p><a href="login.php">Click here to login</p> </div> </div> </div> </body> </html> <?php } ?> <?php extract($_POST); $self = $_SERVER['PHP_SELF']; $user_id = isset($_REQUEST['userid']) ? $_REQUEST['userid'] : ''; $first_name = isset($_REQUEST['firstname']) ? $_REQUEST['firstname'] : ''; $last_name = isset($_REQUEST['lastname']) ? $_REQUEST['lastname'] : ''; $password_one = isset($_REQUEST['password']) ? $_REQUEST['password'] : ''; $password_two = isset($_REQUEST['password2']) ? $_REQUEST['password2'] : ''; $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : ''; $agree = isset($_REQUEST['agree']) ? $_REQUEST['agree'] : ''; $signup = isset($_REQUEST['signup']) ? $_REQUEST['signup'] : ''; $table = isset($_REQUEST['table']) ? $_REQUEST['table'] : ''; if (isset($_REQUEST['signup'])) { $expression = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/"; $errors = 0; if(!isset($user_id) or strlen($user_id) < 5) { echo "<br/>\nUser ID must be 5 letters or longer<br/>\n"; $errors++; } if(!ctype_alnum($user_id)) { echo "<br/>\nUser id should contain alphanumeric values only<br/>\n"; $errors++; } if(mysql_num_rows(mysql_query("SELECT userid FROM sign_up WHERE userid = '$userid'"))) { echo "<br/>\nThis User ID already exists. Please try another one<br/>\n"; $errors++; } if (strlen($password_one) < 6 ) { echo "<br/>\nPassword must be more than 6 char legth<br/>\n"; $errors++; } if ($password_one <> $password_two) { echo "<br/>\nPasswords are not matching<br/>\n"; $errors++; } if(strlen($email) == 0) { echo "Please go back and check (ex:abcd123@hotmail.com)<br/>\n"; $errors++; } if (! $agree == "yes") { echo "<br/>\nYou must agree to terms and conditions<br\>\n"; $errors++; } if($errors >= 1) { echo "<br/>\n<input type='button' value='Retry' onClick='history.go(-1)'>\n"; } if($errors == 0) { display_signup_output_page(); $query = "insert into sign_up(userid,password,email,firstname,lastname,sex) values('$userid','$password','$email','$firstname','$lastname','$sex')"; $result = mysql_query($query,$db_link); $query2 = "insert into members(username,password,email) values('$userid','$password','$email')"; $result2 = mysql_quert($query2,$db_link); echo "<br/><h1>Welcome,\n You have successfully signed up\n<br/><br/>\n<a href=login.php>Click here to login</a><br/>\n"; } } ?>
  4. here is my code to generate and display thumbnail function createthumbnail($name,$filename,$width,$height) { $system = explode('.',$name); if (preg_match('/jpg|jpeg/',$system[1])) { $image = imagecreatefromjpeg($name); } if (preg_match('/png/',$system[1])) { $image = imagecreatefrompng($name); } $x = imageSX($image); $y = imageSY($image); if ($x > $y) { $thumb_w= $width; $thumb_h= $y*($height/$x); } if ($x < $y) { $thumb_w= $x*($width/$y); $thumb_h= $height; } if ($x == $y) { $thumb_w = $width; $thumb_h = $height; } $dst_img = ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$image,0,0,0,0,$thumb_w,$thumb_h,$x,$y); if (preg_match("/png/",$system[1])) { imagepng($dst_img,$filename); } else { imagejpeg($dst_img,$filename); } imagedestroy($dst_img); imagedestroy($image); } while ($row = mysql_fetch_assoc($result)) { print "<tr>\n"; foreach ($row as $col_value) { print "<tb>"; createthumbnail('pics/beautifulWebDesign.jpg','pics/beautifulWebDesign.jpg',100,100); print "</tb>\n"; $col_value = htmlspecialchars(stripslashes($col_value)); print "<td>$col_value</td>\n"; } $isbn = $row['isbn']; ?> <form action="<?php echo $self?>" method="POST"> <td> <input type="hidden" name="isbn" value="<?php echo $isbn?>"> <input type="text" name="quantity" value="1" size="2"> <input type="submit" name="add" value="add"> </td> </form> <?php } ?> i want the image to be displayed in the pictures column down all the rows, but when i run it i get this. no image is being displayed and i am not even getting any error messages.
  5. would i need to make host:localhost:3306 or is localhost fine
  6. guys if i use the mysql_connect command from php to connect to a mysql server, but information do i need to provide if i want to connect to this particular server and bookstore database in that server here is an image i need the information from:
  7. this is my sign up page code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php require('db_connect.php'); $database = "bookstore"; $db_link = db_connect($database); date_default_timezone_set('America/New_York'); display_signup_page(); ?> <?php function display_signup_page() { ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <link href="books.css" rel="stylesheet" type="text/css"> <link href="reset.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sign Up</title> <script type="text/javascript"> function validate(table) { if (!document.table.agree.checked){ alert("Please Read the guidlines and check the box below ."); return false; } return true; } </script> <style type="text/css"> .style1 { font-size: medium; } .style2 { margin-left: 240px; } </style> </head> <body> <div id="pageWrap"> <div id="header"> </div> <div id="navBar"> <ul> <li><a href="Bookstore.php" title="Homw">Home</a></li> <li><a href="search.html" title="Search">Search</a></li> <li><a href="forum.html" title="Forum">Forums</a></li> <li><a href="login.html" title="Contact">Login</a></li> <li class="end"> <a href="signup.html" title="signup">Sign Up</a></li> <li></li> </ul> </div> <div id="container" class="clearfix"> <div id="centerColumn"> <h2>Create an Account</h2> <p><font size="-1">If you already have a SC Bookstore Account, you can <a href="login.html"> login in here</a>.</font></p> <p class="style1"><strong>Required information</strong></p> <table border='0' width='50%' cellspacing='0' cellpadding='0' align="center"> <form method="post" action="<?php echo $self ?>" onsubmit='return validate(this)'> <input type="hidden" name="table" value="post"> <tr bgcolor='#f1f1f1'><td align="center" colspan=2><font face='Verdana' size='2' ><b>Signup</b></td></tr> <tr ><td > <font face='Verdana' size='2' >User ID</td><td ><font face='Verdana' size='2'><input type="text" name="userid"></td></tr> <tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Password</td><td ><font face='Verdana' size='2'><input type='password' name="password"></td></tr> <tr ><td > <font face='Verdana' size='2' >Re-enter Password</td><td ><font face='Verdana' size='2'><input type='password' name="password2"></td></tr> <tr bgcolor='#f1f1f1'><td style="height: 21px" ><font face='Verdana' size='2' > Email<br> (abcd123@hotmail.com)</td><td style="height: 21px" ><input type='text' name='email'></td></tr> <tr ><td > <font face='Verdana' size='2' >First Name</td><td ><font face='Verdana' size='2'><input type="text" name="firstname"></td></tr> <tr ><td > <font face='Verdana' size='2' >Last Name</td><td ><font face='Verdana' size='2'><input type="text" name="lastname"></td></tr> <tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Sex</td><td ><font face='Verdana' size='2'> <input type='radio' value="male" checked="checked" name="sex">Male <input type='radio' value="female" name='sex'>Female</td></tr> <tr ><td > <font face='Verdana' size='2' >I agree to terms and conditions</td> <td > Yes<input name="agree" type="checkbox" value="yes" />No<input name="agree" type="checkbox" value="no" /></td></tr> </table> <p class="style2"> <input name="signup" type="submit" value="signup"/></p> </div> </div> <div id="footer"> <p> SC Books • Est.2010</p> </div> </body> </html> <?php } ?> <?php function display_signup_output_page() { ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <link href="books.css" rel="stylesheet" type="text/css"> <link href="reset.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>SC BookStore</title> </head> <body> <div id="pageWrap"> <div id="header"> </div> <div id="navBar"> <ul> <li><a href="Bookstore.php" title="Homw">Home</a></li> <li><a href="search.html" title="Search">Search</a></li> <li class="end"><a href="forum.html" title="Forum">Forums</a></li> <li></li> </ul> </div> <div id="container" class="clearfix"> <div id="centerColumn"> <h2> Thank You For Signing Up!</h2> <p> </p> <h3>You Can Login here </h3><p><a href="login.html">Click here to login</p></li> </div> </div> </div> </body> </html> <?php } ?> <?php extract($_POST); $self = $_SERVER['PHP_SELF']; $user_id = isset($_REQUEST['userid']) ? $_REQUEST['userid'] : ''; $first_name = isset($_REQUEST['firstname']) ? $_REQUEST['firstname'] : ''; $last_name = isset($_REQUEST['lastname']) ? $_REQUEST['lastname'] : ''; $password_one = isset($_REQUEST['password']) ? $_REQUEST['password'] : ''; $password_two = isset($_REQUEST['password2']) ? $_REQUEST['password2'] : ''; $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : ''; $agree = isset($_REQUEST['agree']) ? $_REQUEST['agree'] : ''; $signup = isset($_REQUEST['signup']) ? $_REQUEST['signup'] : ''; $table = isset($_REQUEST['table']) ? $_REQUEST['table'] : ''; if (isset($_REQUEST['signup'])) { $expression = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/"; $errors = 0; if(!isset($user_id) or strlen($user_id) < 5) { echo "<br/>\nUser ID must be 5 letters or longer<br/>\n"; $errors++; } if(!ctype_alnum($user_id)) { echo "<br/>\nUser id should contain alphanumeric values only<br/>\n"; $errors++; } if(mysql_num_rows(mysql_query("SELECT userid FROM sign_up WHERE userid = '$userid'"))) { echo "<br/>\nThis User ID already exists. Please try another one<br/>\n"; $errors++; } if (strlen($password_one) < 6 ) { echo "<br/>\nPassword must be more than 6 char legth<br/>\n"; $errors++; } if ($password_one <> $password_two) { echo "<br/>\nPasswords are not matching<br/>\n"; $errors++; } if(strlen($email) == 0) { echo "Please go back and check (ex:abcd123@hotmail.com)<br/>\n"; $errors++; } if ($agree<>"yes") { echo "<br/>\nYou must agree to terms and conditions<br\>\n"; $errors++; } if($errors >= 1) { echo "<br/>\n<input type='button' value='Retry' onClick='history.go(-1)'>\n"; } if($errors == 0) { display_signup_output_page(); $query = "insert into sign_up(userid,password,email,firstname,lastname,sex) values('$userid','$password','$email','$firstname','$lastname','$sex')"; $result = mysql_query($query,$db_link); $query2 = "insert into members(username,password,email) values('$userid','$password','$email')"; $result2 = mysql_quert($query2,$db_link); echo "<br/><h1>Welcome,\n You have successfully signed up\n<br/><br/>\n<a href=login.html>Click here to login</a><br/>\n"; } } ?> when i click the sign up page i am getting this: possibly something is not right, but i traced my code over and over again and cant figure out, please help me find the problem and fix it. i am fairly new to php.
  8. i used to use wamp server before but it gave me too many problems and i did try it with wamp and it still wont connect.
  9. i installed mysql version mysql-4.0.16-win.zip on my pc, guys some other news that might help figure out the problem. i am using microsoft web expression 3, do i have to manually do something with web expression program for it to connect to mysql server or is this the right way.
  10. the error message i get is: Warning: mysql_connect(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-4.0/DST' instead in C:\Users\Kash\Documents\My Web Sites\LU Books\db_connect.php on line 8 Warning: mysql_connect(): Connecting to 3.22, 3.23 & 4.0 is not supported. Server is 4.0.16-nt in C:\Users\Kash\Documents\My Web Sites\LU Books\db_connect.php on line 8 Warning: mysql_connect(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-4.0/DST' instead in C:\Users\Kash\Documents\My Web Sites\LU Books\db_connect.php on line 8 Warning: mysql_connect(): Connecting to 3.22, 3.23 & 4.0 servers is not supported in C:\Users\Kash\Documents\My Web Sites\LU Books\db_connect.php on line 8 the line the error is coming from or rather i posted the whole file: <?php function db_connect() { $host_name = "localhost:3306"; $user_name = "root"; $password = "chennupati"; $db_name = "bookstore"; $db_link = mysql_connect($host_name, $user_name, $password) or die("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>"); mysql_select_db($db_name) or die("Could not select database $db_name"); return $db_link; } ?> and in my script i am using this call to access the function: $db_link = db_connect(); can someone please tell what this error means and how i can fix this.
  11. could you emphasis on what you said because i am fairly new to php.
  12. come on guys someone has to know how to do this. please i really need this code completed by today.
  13. hey i am trying to create a forum where user can write description of their book they are trying to sell and upload image of this book and post it on a forum i got most of the code done, but i have no clue on how to use images with php and mysql if anyone can complete this code with it having images uploaded and posting it on the side of the forum the user posted it would be great. here is my code so far: <?php require("db_connect.php"); /* ------------------------------------------------------------------ Web interface to a MySQL notes database using PHP. This version of notes.php doesn't use the Perl-style here documents -----------------------------------------------------------------*/ // Database table name $database = "bookstore"; $table = "forum"; // Get form parameters and database primary key ($id). Non-existent // values are mapped to the empty string $choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : ""; $forum = isset($_REQUEST['content']) ? $_REQUEST['content'] : ""; $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ""; // Convert choice (button label) to lower case $choice = strtolower($choice); // Escape some special characters such as quotes and double quotes // before storing string in database $forum = addslashes($forum); // create an html page for the form or retrieve submitted data start_html(); // Connect to the database and return a link $db_link = db_connect($database); // First time the script is run we just display an entry form if ($choice == "") { display_entry_form(); } // If submit button was clicked insert new note in database table elseif ($choice == "submit") { insert_note($db_link, $table, $forum); display_entry_form(); display_notes($db_link, $table); } // If display button was clicked display all the notes in the table elseif ($choice == "display") { display_entry_form(); display_notes($db_link, $table); } // If search button was clicked display search results elseif ($choice == "search") { display_entry_form(); display_search_hits($db_link, $table, $forum); } // If delete link was clicked delete the note from the table elseif ($choice == "delete") { if ( delete_note($db_link, $table, $id) ) { display_entry_form(); display_notes($db_link, $table); } else { display_entry_form(); echo "<p><strong>A post with ID# $id was not found</strong></p>\n"; display_notes($db_link, $table); } } // If edit link was clicked display the edit form elseif ($choice == "edit") { if ( $row = select_note($db_link, $table, $id)) { display_edit_form($row); } else { echo "<p><strong>A post with ID# $id was not found</strong></p>\n"; display_notes($db_link, $table); } } // If update button on edit form was clicked so update the note in the table elseif ($choice == "update") { update_note($db_link, $table, $id, $forum); display_entry_form(); display_notes($db_link, $table); } // Cancel button on edit form was clicked so discard any changes elseif ($choice == "cancel") { display_entry_form(); display_notes($db_link, $table); } else { echo "<p>Logic error, unknown choice: $choice</p>"; } mysql_close(); // close DB connection end_html(); exit; // -------------------- End of main script --------------------------- function start_html() { ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <link href="books.css" rel="stylesheet" type="text/css"> <link href="reset.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>SC BookStore</title> </head> <body> <div id="pageWrap"> <div id="header"> </div> <div id="navBar"> <ul> <li><a href="Bookstore.php" title="Homw">Home</a></li> <li><a href="search.html" title="Search">Search</a></li> <li><a href="login.html" title="Forum">Login</a></li> <li class="end"> <a href="signup.php" title="signup">Sign Up</a></li> <li></li> </ul> </div> </div> <h2>Forums</h2> <?php } function end_html() { ?> </body> </html> <?php } /* ------------------------------------------------------------------ Display all the notes in the database table -----------------------------------------------------------------*/ function display_notes($db_link, $table) { echo "<hr>\n<h2>Current Notes</h2>\n<hr>\n"; $query = "SELECT id, DATE_FORMAT(time, '%W, %M %D, %Y at %r') AS time2," . "content FROM $table ORDER BY time DESC"; $result = mysql_query($query, $db_link) or die("Query failed"); $num_rows = mysql_num_rows($result); if ( $num_rows == 0 ) { echo "The database is empty"; } else { while ( $row = mysql_fetch_assoc($result)) { display_note($row); } } mysql_free_result($result); } /* ---------------------------------------------------------------------- Display table entries that match search criteria ---------------------------------------------------------------------*/ function display_search_hits($db_link, $table, $search_string) { $search_string = trim($search_string); if ($search_string == "") { echo "<p><strong>Please enter a search term.</strong></p>\n"; return; } $query = "SELECT id, DATE_FORMAT(time, '%W, %M %D, %Y at %r') AS time2," . "content FROM $table WHERE content LIKE '%$search_string%' " . "ORDER BY time DESC"; $result = mysql_query($query, $db_link) or die("Query failed"); $num_rows = mysql_num_rows($result); echo "<h2>Search found ", $num_rows == 0 ? "nothing" : "$num_rows note", $num_rows > 1 ? "s" : "", " matching \"", stripslashes($search_string), "\"</h2>\n<hr>\n"; if ($num_rows > 0) { while ( $row = mysql_fetch_assoc($result) ) { display_note($row); } } mysql_free_result($result); } /* ---------------------------------------------------------------------- Display Image on forum ---------------------------------------------------------------------*/ function display_image($db_link, $table, /* ------------------------------------------------------------------------- Display a row from the database table as an HTML table ------------------------------------------------------------------------*/ function display_note($row) { // extract data from table row $id = $row['id']; $forum = htmlspecialchars(stripslashes($row['content'])); $time = $row['time2']; // store command and record id in the url as a query string $this_url = $_SERVER['PHP_SELF']; $edit_url = "$this_url?choice=edit&id=$id"; $delete_url = "$this_url?choice=delete&id=$id"; // Each note is a table with one row and three columns ?> <table width="100%"> <tr valign="top"> <td width="80%"><b>Time:</b> <?php echo $time?> <pre style="margin-left:2em;margin-top:0.5em;margin-bottom:0.5em"> <?php echo $forum?> </pre> </td> <td width="10%"><a href="<?php echo $edit_url?>">[ Edit ]</a></td> <td width="10%"><a href="<?php echo $delete_url?>">[ Delete ]</a></td> </tr> </table> <hr> <?php } /*------------------------------------------------------------------------- Display a blank data entry form ------------------------------------------------------------------------*/ function display_entry_form() { $script_url = $_SERVER['PHP_SELF']; # url of this script ?> <form method="post" action="<?php echo $script_url?>" enctype="multipart/form-data"> Enter Your Details, Description and Overview of the book your selling. <p> <textarea name="content" rows="5" cols="50" wrap="hard"></textarea> </p> <p> <input type="submit" name="choice" value="Submit"> <input type="submit" name="choice" value="Display"> <input type="submit" name="choice" value="Search"> /*------------------------------------------------------------------------- THIS IS WHERE I NEED TO IMPLEMENT IMAGE UPLOAD AND THE PROCESSING SHOULD TAKE PLEASE IN ONE OF FUNCTIONS SEPERATLY BELOW. ------------------------------------------------------------------------*/ </p></form> <?php } /* ------------------------------------------------------------------------ Display form for editing a note $row is the table row to edit -----------------------------------------------------------------------*/ function display_edit_form($row) { // extract data from the array $row (record). // Slashes added by addslashes are now removed // Also it is necessary to convert html tags to their entities // (For example, < is converted to <) $script_url = $_SERVER['PHP_SELF']; $id = $row['id']; $forum = htmlspecialchars(stripslashes($row['content'])); // Display the form with the current note so that the content can be edited. // We keep track of the id number using a hidden field. ?> <strong>Edit Your Post Here. </strong><br /> <form method="POST" action="<?php echo $script_url?>"> <input type="hidden" name="id" value="<?php echo $id?>"> <textarea name="content" rows="5" cols="50" wrap="hard">$forum</textarea> <p> <input type="submit" name="choice" value="Update"> <input type="submit" name="choice" value="Cancel"> </p> </form> <?php } // DATABASE FUNCTIONS ---------------------------------------------------- /* ----------------------------------------------------------------------- Delete a note given the note id Returns true if sucessful ----------------------------------------------------------------------*/ function delete_note($db_link, $table, $id) { $query = "DELETE FROM $table WHERE id = '$id'"; @mysql_query($query, $db_link); $result = mysql_affected_rows($db_link); return $result > 0; } /* ----------------------------------------------------------------------- Insert a note into the table. ----------------------------------------------------------------------*/ function insert_note($db_link, $table, $forum) { if (trim($forum) != "") { $query = "INSERT INTO $table SET time = NOW(), content = '$forum'"; $result = mysql_query($query, $db_link) or die("<p>Insertion failed</p>\n"); } } /* ------------------------------------------------------------------------ Select a note with a given id (find). Return the record found (row) -----------------------------------------------------------------------*/ function select_note($db_link, $table, $id) { $query = "SELECT * FROM $table WHERE id = '$id'"; $result = mysql_query($query, $db_link) or die("<p>Select note failed</p>\n"); $row = mysql_fetch_assoc($result); return $row; } /* ----------------------------------------------------------------------- Update note content ----------------------------------------------------------------------*/ function update_note($db_link, $table, $id, $forum) { $query = "UPDATE $table SET content = '$forum' WHERE id = '$id'"; $result = mysql_query($query, $db_link) or die("<p>Update note failed</p>\n"); } ?>
  14. hey i am also trying to do something like this, but i want to display the username of the logged in user at the top of my navigation bar on every page and if the user decides to log out the navigation bar no longer would display the username. how about do i do this. i am fairly new to php so a clear explanation would be appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.