Jump to content

MasonPrice

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Everything posted by MasonPrice

  1. @CloudSex13 no problem dude enjoy happy coding glad I could help
  2. if your like me and cant really understand php by reading this youtube channel is perfect for beginners enjoy http://www.youtube.com/user/phpacademy
  3. i just wrote this while i was eating some ribs it works great!!!! if you dont want them to refresh the page and keep adding +1 would need to add their ip address to your database and kill the script if they already view'd the page on that day if your still having trouble just let me know <?php include ("connect.php"); $query = mysql_query("SELECT * FROM view_counting"); while($roww = mysql_fetch_array($query)) { $id = $roww["id"]; $username = $roww["pagename"]; $views = $roww["views"]; echo"<a href='simplecounter.php?id=$id&username=$username&views=$views'>$username</a><br>"; } ?> <?php $id = @$_GET['id']; $views = @$_GET['views']; $username = @$_GET['username']; mysql_query("UPDATE view_counting SET views = '$views'+1 WHERE id = '$id' AND pagename= '$username'"); $sql = mysql_query("SELECT * FROM view_counting WHERE id = '$id' AND views = '$views'AND pagename= '$username'"); while($row = mysql_fetch_array($sql)) { $id = $row["id"]; $username = $row["pagename"]; $views = $row["views"]; } echo "$username you have $views "; ?>
  4. i think i can help you with this, but let me see if i understand what your trying to do first ....... do you want to add 1 count every time a user clicks on a userprofile link (userprofile.php?userid=1001 ect.) ????
  5. i have made the changes you suggested with a little of my own changes to the form but i still do not get any results to pass to the next page ?????? Any one else has any idea your help would be appreciated................................. thanks in advance <?php include ('connect.php'); ?> <?php echo"<h3>Please enter your search Username</h3> <form action='search.php' method='get'> <input name='username' size='40' maxlength='32'/> <input type='submit' name="submit" value='Submit' /> </form>"; ?> <hr width="800"> <?php if (isset($_GET["submit"])) { $username = ($_GET["username"]); $per_page =5; $start = @$_GET['start']; $record_count = mysql_num_rows(mysql_query("SELECT * FROM register WHERE username LIKE '%$username%' ORDER BY username")); $max_pages = $record_count / $per_page; if(!$start) $start = 0; $query = mysql_query("SELECT * FROM register WHERE username LIKE '%$username%'ORDER BY username LIMIT $start, $per_page "); $exist = mysql_num_rows($query); if($exist=='0') { echo "No match found"; } else { echo "Your matches for: <b>$username</b><br><br>"; while($currow = mysql_fetch_array($query)) { $username = ($currow['username']); ?> <?php echo"<a href='../mysite/$username'>$username</a><br>" ; } } ?> <?php $prev = $start - $per_page; $next = $start + $per_page; echo"<br>"; if(!($start<=0)) echo "<a href='{$_SERVER['PHP_SELF']}?start=$prev&username=$username'>Prev</a> "; $i=1; for($x=0;$x<$record_count;$x=$x+$per_page) { if($start!=$x) echo "<a href='{$_SERVER['PHP_SELF']}?start=$x&$username=$username'>$i</a>"; else echo "<a href='{$_SERVER['PHP_SELF']}?start=$x&username=$username'>$i</a> "; $i++; } if(!($start>=$record_count-$per_page)) echo "<a href='{$_SERVER['PHP_SELF']}?start=$next&username=$username'>Next</a>"; echo" $next"; echo"<br><br>"; } ?> </div> </body> </html> <?php include ('footer.php'); ?>
  6. i know its not posted can you show me how to posted please
  7. i need some help.....im using a basic form with pagination, but it does not seem to be working for some reason it displays the username i search for the first time but when i click on the next button i get no more results even though i have like 30 more results left in the database ........... any help would be appriciated thanks in advance Here is the code i am using <?php include ('connect.php'); ?> <?php echo"<h3>Please enter your search Username</h3> <form action='search.php?find' method='post'> <input name='username' size='40' maxlength='32'/> <input type='submit' value='Submit' /> </form>"; ?> <hr width="800"> <?php if (isset($_GET["find"])) { $username = ($_POST["username"]); $per_page =5; $start = @$_GET['start']; $record_count = mysql_num_rows(mysql_query("SELECT * FROM register WHERE username LIKE '%$username%' ORDER BY username")); $max_pages = $record_count / $per_page; if(!$start) $start = 0; $query = mysql_query("SELECT * FROM register WHERE username LIKE '%$username%'ORDER BY username LIMIT $start, $per_page "); $exist = mysql_num_rows($query); if($exist=='0') { echo "No match found"; } else { echo "Your matches for: <b>$username</b><br><br>"; while($currow = mysql_fetch_array($query)) { $username = ($currow['username']); echo"</td> </tr> </table>"; ?> <?php echo" <a href='../mysite/$username'>$username</a><br>" ; } } ?> <?php $prev = $start - $per_page; $next = $start + $per_page; echo"<br>"; if(!($start<=0)) echo "<a href='{$_SERVER['PHP_SELF']}?start=$prev'>Prev</a> "; $i=1; for($x=0;$x<$record_count;$x=$x+$per_page) { if($start!=$x) echo "<a href='{$_SERVER['PHP_SELF']}?start= $x'>$i</a> "; else echo "<a href='{$_SERVER['PHP_SELF']}?start= $x'>$i</a> "; $i++; } if(!($start>=$record_count-$per_page)) echo "<a href='{$_SERVER['PHP_SELF']}?start=$next'>Next</a>"; echo" $next"; echo"<br><br>"; } ?> </div> </body> </html> <?php include ('footer.php'); ?>
  8. ok i will surelly do that im gonna run tru the script again for the 100 time ... tanx for the advice
  9. i have been troubleshooting this script all weekend i even have my brother trying to help me figure out the problem to no avail i have tried all of the suggestions posted here and still stuck.... ??? this is the ERROR:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'Mason'' at line 1 can this be the problem: CREATE TABLE user_info ( email varchar (50) NOT NULL, username varchar (50) NOT NULL, password varchar (255) NOT NULL, first_name varchar (50) NOT NULL, last_name varchar(50) NOT NULL, city varchar(50) default NULL, state varchar(50) default NULL, hobbies varchar(255) default NULL, id int(10) NOT NULL default '0' ); i have posted the whole entire script on here can someone please run it and tell me if they get the same result...please and thank you in advance
  10. same error different day: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'Mason Price'' at line 1 this is when i try to register im clueless when i register its sappose to take me to this page: personal page.php <title>Untitled Document</title> </head> <body> <?php include "auth_user.inc.php"; include "conn.inc.php"; ?> </body> </html> <html> <head> <title>hello</title> </head> <body> <h1>Welcome to your personal information area</h1> <p> Here you can update your personal information, or delete your account.<br> Your information as you currently have it is shown below:<br> <a href="index.php">Click here</a> to return to the home page<br><br> <?php $query = "SELECT * FROM user_info " . "WHERE username = '". $_SESSION['user_logged'] . "' " . "AND password = (PASSWORD('". $_SESSION['user_password'] . "'))"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); ?> First Name: <?php echo $row['first_name']; ?><br> Last Name: <?php echo $row['last_name']; ?><br> City: <?php echo $row['city']; ?><br> State: <?php echo $row['state']; ?><br> Mail: <?php echo $row['mail']; ?><br> Hoddies/Interests: <?php echo $row['hobbies']; ?><br><br> <a href="update_account.php">Update Account</a> | <a href="delete_account.php">Delete Account</a> </p> </body> </html>
  11. no dude did not work i still get this dreaded error im really obsessive about it to...lol You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'Mason Price'' at line 1
  12. both loggin and registerwhen i try to loggin i get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'Mason' AND password = (PASSWORD('test'))' at line 1 when i register i get the above error its driving my crazy the funny thing is i copy this from a book i went line for line to make sure i did it exactly how its in the book and still i cant find the error but i will try it out like you say i will get back to ya thanks for the reply/advice.....b rigth bac
  13. ??? hey whats up guys? im noobie to php & mysql i have been recently trying to create a loggin/register page but i keep getting this annoying error when i try to register:----> You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'demo'' at line 1 i have been going tru and tru the code trying to figure the problem out my self but i still dont see it can someone please help me? here is the code: login.php <title>Untitled Document</title> </head> <body> <?php session_start(); include "conn.inc.php"; if (isset($_POST['submit'])) { $query = "SELECT username, password FROM user_info". "WHERE username = '" . $_POST['username'] . "' ". "AND password = (PASSWORD('". $_POST['password'] . "'))"; $result = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) == 1) { $_SESSION['user_logged'] = $_POST['username']; $_SESSION['user_password'] = $_POST['password']; header ("Refresh: 5; URL" . $_POST['redirect'] . ""); echo "You are being redirected to the original page requested!<br>"; echo "(If your browser doesn't support this , " . "<a href=\"" . $_POST['redirect']. "\">click here</a>)"; } else { ?> </body> </html> <html> <head> <title>Hello Page</title> </head> <body> <p> Invalid Username and/or Password<br> Not registered? <a href="register.php">Click Here</a> to registerd.<br> <form action="user_login.php" method="post"> <input type="hidden" name="redirect" value="<?php echo $_POST['redirect']; ?>"> Username: <input type="text" name="username" ><br> Password: <input type="password" name="password"><br><br> <input type="submit" name="submit" value="Login"> </form> </p> </body> </html> <?php } } else { if (isset($_GET['redirect'])) { $redirect = $_GET['redirect']; } else { $redirect = "index.php"; } ?> <html> <head> <title>Hello Page</title> </head> <body> <p> Login below by supplying your username/password...<br> Or <a href="register.php">Click here</a> to register.<br><br> <form action="user_login.php" method="post"> <input type="hidden" name="redirect" value="<?php echo $redirect; ?>"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br><br> <input type="submit" name="submit" value="Login"> </form> </p> </body> </html> <?php } ?> conn.inc.php <title>conn.inc.php</title> </head> <body> <?php $connection = mysql_connect("host", "name", "pass") or die(mysql_error()); $db = mysql_select_db("databasename") or die(mysql_error()); ?> </body> </html> register.php <?php session_start(); ob_start(); include "conn.inc.php"; ?> <head> <title>Hello Page</title> </head> <body> <?php if (isset($_POST['submit']) && $_POST['submit'] == "databasename") { if ($_POST['username'] != "" && $_POST['password'] != "" && $_POST['first_name'] != "" && $_POST['last_name'] != "" && $_POST['email'] != "" ) { $query = "SELECT username FROM user_info" . "WHERE username = '". $_POST['username'] . "';"; $result = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) != 0) { ?> <p> <font color="#FF0000">The Username, <?php echo $_POST['username']; ?>, is already in use, please choose another!</br></font> <form action="register.php" method="post"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password" value="<?php echo $_POST['password']; ?>"><br> Email: <input type="text" name="email" value="<?php echo $_POST['email']; ?>"><br> First Name: <input type="text" name="first_name" value="<?php echo $_POST['first_name'];?>"><br> Last Name:<input type="text" name="last_name" value="<?php echo $_POST['last_name'];?>"><br> City:<input type="text" name="city" value="<?php echo $_POST['city'];?>"><br> State:<input type="text" name="state" value="<?php echo $_POST['state'];?>"><br> Hobbies/Interests:(Choose at least one)<br> <select name="hobbies[]" size="10" multiple> <option value="Golfing"<?php if (in_array("Golfing", $_POST['hobbies'])){ echo "selected"; } ?>>Golfing</option> <option value="Hunting"<?php if (in_array("Hunting", $_POST['hobbies'])){ echo "selected"; } ?>>Hunting</option> <option value="Reading"<?php if (in_array("Reading", $_POST['hobbies'])){ echo "selected"; } ?>>Reading</option> <option value="Dancing"<?php if (in_array("Dancing", $_POST['hobbies'])){ echo "selected"; } ?>>Dancing</option> <option value="Internet"<?php if (in_array("Internet", $_POST['hobbies'])){ echo "selected"; } ?>>Internet</option> <option value="Flying"<?php if (in_array("Flying", $_POST['hobbies'])){ echo "selected"; } ?>>Flying</option> <option value="Traveling"<?php if (in_array("Traveling", $_POST['hobbies'])){ echo "selected"; } ?>>Traveling</option> <option value="Excersising"<?php if (in_array("Exercising", $_POST['hobbies'])){ echo "selected"; } ?>>Exercising</option> <option value="Computers"<?php if (in_array("Computers", $_POST['hobbies'])){ echo "selected"; } ?>>Computers</option> <option value="Other Than Listed"<?php if (in_array("OtherThan Listed", $_POST['hobbies'])){ echo "selected"; } ?>>Other Than Listed</option> </select><br><br> <input type="submit" name="submit" value="Register"> <input type="reset" value="Clear"> </form> </p> <?php } else { $query = "INSERT INTO user_info (username, password, email, ". "first_name, last_name, city, state, hobbies) ". "VALUES ('". $_POST['username'] ."',". "(PASSWORD('" . $_POST['password'] ."')), '". $_POST['email'] . "','" . $_POST['first_name'] . "', '" .$_POST['last_name'] . "', '" . $_POST['city']. "', '". $_POST['state'] . "', '" . implode(", ", $_POST['hobbies']) . "');"; $result = mysql_query($query) or die (mysql_error()); $_SESSION['user_logged'] = $_POST['username']; $_SESSION['user_password'] = $_POST['password']; ?> <p> Thank you, <?php echo $_POST['first_name'] . " " . $_POST['last_name']; ?>for registering!<br> <?php header ("Refresh: 5; URL=index.php"); echo"your registration is complete! " . "you are being sent to the page you requested!<br>"; echo"(If your Browser doesn't support this, " . "<a href=\"index.php\">click here</a>"; die(); } } else { ?> <p> <font color="#FF0000"><b>The Username, Password, Email, First Name, and Last Name fields are required!</b></font> <form action="register.php" method="post"> Username:<input type="text" name="username" value="<?php echo $_POST['username']; ?>"><br> Password:<input type="password" name="password" value="<?php echo $_POST['password']; ?>"><br> Email:<input type="text" name="Email" value="<?php echo $_POST['email']; ?>"><br> First Name:<input type="text" name="first_nAme" value="<?php echo $_POST['first_name']; ?>"><br> Last Name:<input type="text" name="last_name" value="<?php echo $_POST['Last_name']; ?>"><br> City:<input type="text" name="city" value="<?php echo $_POST['city']; ?>"><br> State:<input type="text" name="state" value="<?php echo $_POST['state']; ?>"><br> Hobbies/Interests: (choose at least one) <br> <select name="hobbies[]" size="10" multiple> <option value="Golfing"<?php if (in_array("Golfing", $_POST['hobbies'])) { echo "selected"; } ?>>Golfing</option> <option value="Hunting"<?php if (in_array("Hunting", $_POST['hobbies'])) { echo "selected"; } ?>>Hunting</option> <option value="Reading"<?php if (in_array("Reading", $_POST['hobbies'])) { echo "selected"; } ?>>Reading</option> <option value="Dancing"<?php if (in_array("Dancing", $_POST['hobbies'])) { echo "selected"; } ?>>Dancing</option> <option value="Internet"<?php if (in_array("Internet", $_POST['hobbies'])) { echo "selected"; } ?>>Internet</option> <option value="Flying"<?php if (in_array("Flying", $_POST['hobbies'])) { echo "selected"; } ?>>Flying</option> <option value="Traveling"<?php if (in_array("Traveling", $_POST['hobbies'])) { echo "selected"; } ?>>Traveling</option> <option value="Exercise"<?php if (in_array("Exercise", $_POST['hobbies'])) { echo "selected"; } ?>>Exercise</option> <option value="Computers"<?php if (in_array("Computers", $_POST['hobbies'])) { echo "selected"; } ?>>Computers</option> <option value="Other Than Listed"<?php if (in_array("Other Than Listed", $_POST['hobbies'])) { echo "selected"; } ?>>Other Than Listed</option> </select><br><br> <input type="submit" name="submit" value="Register"> <input type="reset" value="Clear"> </form> </p> <?php } } else { ?> <p> Welcome to the registration page!<br> The Username, Password, Email, First Name, and Last Name fields are required! <form action="register.php" method="post"> Username:<input type="text" name="username"><br> Password:<input type="password" name="password"><br> Email:<input type="text" name="email"><br> First Name:<input type="text" name="first_name"><br> Last Name:<input type="text" name="last_name"><br> City:<input type="text" name="city"><br> State:<input type="text" name="state"><br> Hoddies/Interest: (Choose at least one)<br> <select name="hobbies[]" size="10" multiple> <option value="Golfing">Golfing</option> <option value="Hunting">Hunting</option> <option value="Reading">Reading</option> <option value="Dancing">Dancing</option> <option value="Internet">Internet</option> <option value="Flying">Flying</option> <option value="Traveling">Traveling</option> <option value="Excercising">Excercising</option> <option value="Computers">Computers</option> <option value="Other Than Listed">Other Than Listed</option> </select><br><br> <input type="submit" name="submit" value="Register"> <input type="reset" value="Clear"> </form> </p> <?php } ?> </body> My Database is called "registration" CREATE TABLE user_info ( email varchar (50) NOT NULL, username varchar (50) NOT NULL, password varchar (255) NOT NULL, first_name varchar (50) NOT NULL, last_name varchar(50) NOT NULL, city varchar(50) NULL state varchar(50) NULL hobbies varchar(255) NULL id int(10) NOT NULL defaut '0' ); (edited to add tags)
×
×
  • 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.