Jump to content

SN1P3R_85

Members
  • Posts

    90
  • Joined

  • Last visited

    Never

Everything posted by SN1P3R_85

  1. i made that change, and it still wont' display the correct css
  2. <?php error_reporting(E_ALL); include('../user.inc'); include('../SQL_PASS.inc'); if(!$user) { header('Location:http://www.caidenhome.com/access_denied.php'); } if(!$con) { die('could not connect: ' . mysql_error()); } if(!$db_select) { die('could not select database: ' . mysql_error()); } $sql_fetch = "SELECT * FROM `threads`"; $sql_query = mysql_query($sql_fetch); if(!$sql_fetch) { die('could not run query: ' . mysql_error()); } if (mysql_num_rows($sql_query)==0) { echo "<p>there are no threads at the moment</p>"; } else { echo '<table class="forum_menu" border="1" width="10%">'; while ($row = mysql_fetch_assoc($sql_query)) { echo '<tr style="height:20px"><td class="forum" width="50%"><a href="/forum/forum_display.php?id=' . $row['Thread_id'] . '>' . $row['Thread_name'] . '</td></tr>'; } echo "</table>"; } ?> <html> <head> <title>forum_menu</title> <link rel="stylesheet" type="text/css" href="/css/standard.css" /> </head> <body> <table class="lnk_bar" border="1" width="100%"> <tr> <td width="20%"><b><a href="/index.php">home</a></b></td> <td width="20%"><b><a href="/calc.php">calculator</a></b></td> <td width="20%"><b><a href="/cobolt.mp3">song</a></b></td> <td width="20%"><b><a href="/forums/forum_menu.php">forum</a></b></td> <td width="20%"><b><a href="/register.php">register</a></b></td> </tr> </table> <a class="thread_create" href="/forum/create_thread.php">start thread</a> </body> </html>
  3. I added that line. all i got is this: Notice: Undefined index: User_level in /homepages/12/d222097102/htdocs/user.inc on line 11. This is a different script, and that undefined index is because of whitespace i think. Anyways, it shouldn't have anything to do with the forum_menu.php file.
  4. On one of my pages, none of the css is displayed, and neither is a certain table. If i take the html and put it in a file, it works fine, but in combination with the php, it doesn't work. Here is the code for the table, can you guys see anything wrong with it?: echo '<table class="forum_menu" border="1" width="10%">'; while ($row = mysql_fetch_assoc($sql_query)) { echo '<tr style="height:20px"><td class="forum" width="50%"><a href="/forum/forum_display.php?id=' . $row['Thread_id'] . '>' . $row['Thread_name'] . '</td></tr>'; } echo "</table>";
  5. Thanks alot for the help, cleared up alot of my problems.
  6. It works, could you tell me what you changed, and why mine wasn't working?
  7. Hi, i want to echo a table, and in the table, i have links to certain pages. Each page name is stored in an sql database. I tried to write it, but i keep getting syntax errors. This is what i have: echo "<table class=\"forum\" border=\"1\" width=\"40%\"><tr style=\"height:20px\"><td class=\"forum\" width=\"50%\"><a href=\"/forum/" . $row['Thread_name'] . "_" . $row['Id'] . ".php\">$row['Thread_name']</a></td></tr>"; p.s. - i end the table somewhere else, so don't worry about that.
  8. hey, thanks for the help, i got it to work. The mysql code you gave me worked fine, it was a weird syntax error. I never found out what it was, my code looked fine, so i copied a piece of code from another file and it worked. Before i leave, could you tell me what that MYSQL_BOTH does?
  9. nothing at all. btw, what does MYSQL_BOTH do?
  10. i dont' understand why this wont' work, this makes sense. I am using my login table to test it. it should echo the first element of the array. <?php $select_maxid = mysql_query("SELECT MAX(Id) FROM `login`"); $row1 = mysql_fetch_array($select_maxid, MYSQL_BOTH); $max_id = $row1[0]; echo $max_id; ?>
  11. All of this just finds the max id in the table and stores it? Is there anything wrong with the query: mysql_query("SELECT MAX(Id) FROM `threads`"); is it possible to store just this query in a variable?
  12. ok, what i meant was, can one of you guys show me how to store that query in a variable.
  13. Hi, i want to run this query, and store the results in a php variable: mysql_query("SELECT MAX(Id) FROM `threads`");
  14. i have been programming php for like 2 weeks i need to learn how to do this stuff right. Thanks for your help, im gonna start rewriting all this code
  15. hmm, ok, well, i guess i'll start rewriting my userscript. Do you know why my function didn't work though? it may have been inefficient, but it should have still worked. Did you see anything wrong with it?
  16. hmm, So when someone logs on i should make a session variable, and then just check for the session variable? Is there anyway to manipulate session variables, im worried about security. I would also have to make it so it checked if the cookie existed, and if it did, remake the session variable. I could do it that way if its better.
  17. ok, im gonna post my entire user script so you can see how it works. I already have something along the lines of this, im just trying to make a nifty function i can put into anything i don't want non-users to see. Ok, here is the user script: <?php if ( array_key_exists( 'id', $_COOKIE ) && array_key_exists( 'pass', $_COOKIE )) //this checks that id and password cookies are set { include( 'SQL_PASS.inc' ); //my sql login info $sql_fetch = "SELECT * FROM login WHERE Id = '{$_COOKIE['id']}' AND Password = '{$_COOKIE['pass']}' LIMIT 1"; $lgn_result = mysql_query($sql_fetch); if (!$lgn_result) { die('Could not run query: ' . mysql_error()); } if (mysql_num_rows($lgn_result) == 0) { die('Wrong username or password, exiting'); } $user = mysql_fetch_object( $lgn_result ); } else { $user = false; } function user_valid() { if ($user) {} else { header('Location:http://www.caidenhome.com/access_denied.php'); } } ?>
  18. it says im logged out no matter what. If i do it while im logged out, it tries to make me log in, if i do it logged in, it tries to make me log in again. If i take the contents of the function and put it in place of the function, it works.
  19. hmm, why start a session variable? I'm just curious. If i do this it works: <?php include('../user.inc'); if ($user) { include( 'forum_menu.inc' ); } else { header('Location:http://www.mysite.com/access_denied.php'); } ?> its just when i put it in a function to try make it easier, it wont' work.
  20. hi, I am trying to make a function that will check a users status when viewing certain pages, to make sure they're logged on. If a user exists, then the variable $user will be true. So i made this function: <?php function user_valid() { if (!$user) { header('Location:http://www.mysite.com/access_denied.php'); } } ?> Then i made a test file to see if my function would work, and it didn't. I logged myself on, and then ran this code, and it said that I wasn't logged on, even though i was. here is the code: <?php include( '../user.inc' ); //contains my function, and is also where i declare $user. user_valid(); echo "you're logged in!"; ?> It keeps saying im not logged on, even though i am. Can php functions be used like this?
  21. Hi everyone, i made a very basic forum on my site. So far, users can post, and it works fine. Now i want to make it so users can start their own threads, but im not sure how i would go about this. Basically, i would need it to create a file called "users_thread.php", and it would be called whatever the user wanted it to be. I have the code for the forum, but i dont' know how i would make a user able to create a new thread. Any ideas? thanks.
  22. I store the session exactly like this: <?php session_start(); $_SESSION['return_url'] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; ?> Is this the wrong way? how long do sessions last? i thought they lasted until the person left the website.
  23. i tried echoing it, and i got nothing, so maybe its not valid. Do you know a good way to get the url of the current page you're on. In the format so i can just stick it in the header like this: header("Location: $url");
  24. I posted about this earlier today, and i think i went about explaining my problem the wrong way. I want to redirect one of my pages to a another page, but i stored the location in a variable. On a previous page i stored the url by doing this: $_SESSION['return_url'] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; Now after the user does something, it should redirect them back to that page. I am not sure how to include the variable in the location. I've tried this, and it doesn't redirect at all. $url = $_SESSION['return_url']; header("Location: $url"); Basically, i just need to know how to use a variable instead of a direct url. Also, if you know a better way to store a url than this, go ahead and tell me: $_SESSION['return_url'] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
×
×
  • 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.