Jump to content

LooieENG

Members
  • Posts

    236
  • Joined

  • Last visited

    Never

Everything posted by LooieENG

  1. Have you tried <?php mail('you@domain.com', 'test', 'test'); ?> If it doesn't work it's a problem with mail, not your script Edit: Also, you don't actually connect to the database. <?php $con = mysql_connect($db_server, $db_username, $db_password); mysql_select_db($db_name, $con); ?>
  2. $result = mysql_query("SELECT username FROM users WHERE username = '$_POST[username]'"); if ( mysql_num_rows($result) > 0 ) { echo 'Username exists'; } else { // stuff } (Used $_POST['username'] as an example)
  3. echo "<a href=\"edit_info.php?user={$row['user']}\">EDIT!</a>"; And then on the next page $user = $_GET['user'];
  4. Something like this? I list the blog posts, with a hyperlink for admin.php?do=edit&id=id (use GET) then I get the blog content from the table with that id, and set a variable. Then, in the html bit, if the variable is set, it echos a textarea with the blog content in it, and when the content is edited, the data is submitted with POST and changed
  5. Don't know if this has anything to do with it, but you check if $rows2 is 1, but $rows2 is never defined
  6. Thanks. Also, just quickly, is there a significant difference between TEXT and BLOB, and is it better to use VARCHAR? I think I read something like text/blob will always be the same size, whereas varchar is as big as the data it contains plus one byte? Is this right? And is this good for a blog post table? id > tinyint title > tinytext content > text user > varchar(32) time > int Thanks.
  7. What column type should I have to store a timestamp (like 142567442)? If I choose timestamp, it makes it YYYY-MM-DD HH-MM-SS. Just bigint?
  8. is the folder "images" CHMODed to 777?
  9. Should that not be <?php $query = "INSERT INTO active_users (nowonline) VALUES ('$page')"; $sql = "SELECT (nowonline) FROM active_users"; $verify = mysql_query($query) or die(mysql_error()); $verified=mysql_query($sql)or die(mysql_error()); if($verify) { //dostuff }else{ //error } if($verified) { //dostuff }else{ //error } ?>
  10. Make a folder called styles with style1.css, style2.css, etc. Then, say the page is index.php, do index.php?style=(number of style) And before the HTML tags <?php if ( isset($_COOKIE['style']) ) { $s = 'styles/style' . $_COOKIE['style'] . '.css'; } elseif ( isset($_GET['style'] && ctype_digit($_GET['style']) ) { $s = 'styles/style' . $_GET['style'] . '.css'; setcookie('style', $s, time()+(99999*99999), '/'); } else { // Default style $s = 'styles/style1.css'; } ?> And in the <head> tags of the HTML <link rel="stylesheet" type="text/css" href="<?php echo $s?>" /> Try that, it SHOULD work. Make sure the page ends in .php, not .html You can also probably do it with JavaScript, but I don't really know any, so you'll have to wait for someone who does post
  11. Place a footer div at the bottom, and use #footer { clear: both; } Should fix it
  12. For the div on the left of where the ad should be, use margin: 0 120px 0 0; Looks like you've worked it out from your link though
  13. Oh, I once had an annoying white border at the top of my page, and it turned out I somehow managed to place a <br /> tag in the <head> section :-\ Have you checked your stylesheet for a{} and .message_rows_subject{}?
  14. mysql_query("INSERT INTO active_users (nowonline) VALUES '$SERVER[php_SELF]'");
  15. Little white border where, at the top of the page?
  16. Add a column to "posts" or whatever called last_post, then when someone posts, add a timestamp to it. Then use something like $result = mysql_query("SELECT * FROM posts ORDER BY last_post DESC"); I Think that should work
  17. Woops, forgot to remove those when I edited
  18. Can't modify my last post, but it's working now.
  19. <?php //Database Settings $host = 'localhost'); $dbuser = '******'); $pass = '******'); $db = '******'); //MySQL Connection $conn = mysql_connect($host, $dbuser, $pass); if (!conn) { // the connection failed so quit the script die('Could not connect !<br />Please contact the site administrator.'); } $db = mysql_select_db($db); if (!db) { // cannot connect to the database so quit the script die('Could not connect to database <br /> Please contact the site administrator.'); } ?>
  20. The "function", before the actual function means it's setting a function. the $dirname variable relates to the function for example function myFunction($var1, $var2) { echo $var1 . $var2; } The above code means, that when you call the function by typing $var1 = 'hello '; $var2 = 'world!'; myFunction($var1, $var2) It takes the data from the variables $var1 and $var2 are, and uses it in the function. So if you take the above function, but instead of $var1 and $var2, you use 'hello ' and 'world!' like this myFunction('hello ', 'world!') The function takes the values and uses them, so it would echo 'hello world!' So if you do $hi = 'hi. '; $hello = 'hello.'; myFunction($hi, $hello) The function is actually myFunction($hi, $hello) { echo $hi . $hello; } So you set the function first function NameOfFunction($varSomething) { echo $varSomething; } Then you set the variables $hi = 'hi'; Then you call the function, replacing $varSomething with the variable you want the function to echo NameOfFunction($hi) This will echo the word 'hi' because you used $hi, so the function is NameOfFunction($hi) { // Prints the variable used when calling the function echo $hi; } Hope that helps explain it
  21. <?php function printNews($news) { if ( mysql_num_rows($news) < 1 ) { echo "<h1>No news!</h1>"; } else { echo ' <table><tr> <td><h2><u>' . $news['title'] . '</u></h2></td> </tr><tr> <td>' . $news['news'] . '</td> </tr></table><br />'; } } mysql_connect("***", "***", "***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); $query1 = "SELECT * FROM stickynews"; $query2 = "SELECT * FROM news"; $result1 = mysql_query($query1) or die(mysql_error()); $result2 = mysql_query($query2) or die(mysql_error()); while($row1 = mysql_fetch_array($result1)) printNews($row1); while($row2 = mysql_fetch_array($result2)) printNews($row2); ?> Like this?
  22. I see, and using else works, but every time I enter something, it says username not found, but I checked the database and the name does exist. <?php // Starts session session_start(); // Checks if user is already logged in if ( $_SESSION['username'] ) { // User is already logged in, so redirecting to the Admin CP header('location: admin.php'); exit; } // Checks if form has been submitted if ( $_POST['login'] ) { // Checks if username contains alphanumeric characters only if ( !ctype_alnum($_POST['username']) ) { // Sets error and exits $ue = '(Alphanumeric characters only.)'; } else { // Sets variables $username = $_POST['username']; $password = md5('salt' . $_POST['password']); // Opens database connection and selects database $con = mysql_connect('localhost', 'xxxxx, 'xxxxx'); mysql_select_db('xxxxx_blog', $con); // Gets data for username from database $result = mysql_query("SELECT password FROM users WHERE username = '$username'"); // Checks if user exists if ( mysql_num_rows($result) < 1 ) { // Sets error $ue = '(Username not found.)'; } else { // Gets rows from database query $row = mysql_fetch_array($result); // Checks if password matches if ( $password != $row['password'] ) { // Sets error $pe = '(The password you entered is incorrect.)'; } else { // Sets session data and redirects to Admin CP $_SESSION['username'] = $username; header('location: admin.php'); // Exits exit; } } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Login</title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" name="login"> Username: <input name="username" type="text" size="30" /> <?php echo $ue ?><br /> Password: <input name="username" type="password" size="30" /> <?php echo $pe ?><br /> <input name="login" type="submit" value="Log in" /> </form> </body> </html> Thanks
  23. Place the function bit before you use it
  24. if ( mysql_num_rows($queries) < 1 ) { // stuff } Is that what you mean?
×
×
  • 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.