Jump to content

geudrik

Members
  • Posts

    115
  • Joined

  • Last visited

    Never

Everything posted by geudrik

  1. Aye, make sure your session variable is actually declared.
  2. Aren't you doing this for school? Having me do it, even once, WILL NOT help you out in any way what so ever. You won't wind up learning antyhing. Snag a book on php man. note: I already essentially wrote your SQL statment already....
  3. use mysql_close() to close your connection to the database after your table has been outputted. I didn't see that anywhere in your code. See if that helps.
  4. You can, or you can use javascript to do so before the form is actually submitted. That for you I think will make things more complicated. So use PHP to do so, but make sure that if there is an error, its displayed and the info they submitted is sent back to the form. That way if something is wrong, all the work they put into the form wasn't wasted and they don't get frusterated.
  5. http://www.spaazz.net/index.php?pid=4 That's the url right there. That's the only input. Its all links. http://www.spaazz.net/index.php?pagelist If you go there, you see the two pages in the table. That's working correctly minus the main page showing above it.
  6. Mostly because i was up until 4 last night finishing the admin panel :-\ I'll fix that once I get the site working as it should... Any thoughts on why it isnt doing what *i THINK* the code says?
  7. Good call chief. Resource error gone, but it sill isn't working like it should. I fixed that one block ... <?php if(isset($_GET['pid'])) { $id = $_GET['pid']; $sql = "SELECT * FROM cms WHERE id = '$id'"; if( !mysql_query($sql) ) { echo("There was something wrong with the page you requested, so I'm giving up trying to regurgitate the gobble di gook"); } else { $result = mysql_query($sql); while( $row = mysql_fetch_assoc($result) ); { echo($row['body']); } } } ?>
  8. oh, and you need to assign a group to your radio buttons so that you can only click on at a time. As of now, I am able to select them all.
  9. Nah, not working and now I wind up with resource error #4 - check it out live - www.spaazz.net That resource error is only when I try to view a page using ?pid= (use 3 or 4 - that all that exists in the database for now) Current code (has isset() ) <?php include('includes/db.php'); dbconnect(); if(isset($_GET['pid'])) { $id = $_GET['pid']; $sql = "SELECT body FROM cms WHERE id = '$id'"; if( !@mysql_query($sql) ) { echo("There was something wrong with the page you requested, so I'm giving up trying to regurgitate the gobble di gook"); } else { $result = mysql_query($sql); echo($result); } } if( (!isset($_GET['pid'])) || (!isset($_GET['pagelist'])) ) { $homesql = "SELECT body FROM cms WHERE title = 'SpaazZ Home'"; $homeresult = mysql_query($homesql) or die(mysql_error()); while( $row = mysql_fetch_assoc($homeresult) ) { $content = $row['body']; } $homecontent = stripslashes(nl2br($content)); echo($homecontent); } if( isset($_GET['pagelist']) ) { $sql = "SELECT * FROM cms"; $result = mysql_query($sql) or die(mysql_error()); while( $row = mysql_fetch_assoc($result) ) { $id = $row['id']; $title = $row['title']; echo("<a href='index.php?pid=$id'>$title</a><br />"); } } mysql_close(); if( isset($_GET['admin']) ) { include('includes/templates/adminlogin.tpl'); } ?>
  10. It's good that you're starting with the form. Once you have the form designed, you can create a table in your database that matches the info your want to submit. Remember that the easiest way to store form data is in variables once it submitted. $firstname = $_GET['firstname']; And once you have your error checking completed, just plugging and chugging in a sql statement... $sql = "INSERT INTO form (firstname, lastname, comments) VALUES ('$firstname', '$lastname', '$comments')"; mysql_query($sql) or die(mysql_error()); Form processing is really easy once you understand how the form elements interact with the php code and how the php knows which elements are what. Google php form processing and you'll find something simple on how php communicates and handles submitted forms. I hope this help, I wasn't totally sure of what your question was so....
  11. Alright, I'm sure I'm missing something here... As soon as a url has ?page after the .php of the page, the $_GET variable 'page' HAS BEEN SET, right? I mean, it's got no value, I understand that, but IT HAS been declared, yes? Assuming that, the code below is what I am unable to get working... This code is live here. If you click 'Links' at the top of the page, you get a list of pages that exist. However, the main page is ALWAYS displayed at the top (See for your self). How do I change my code around so that only one of three things (with the exception of the admin login - I want that to show up right below the index content when the link is clicked as it does now) is displayed? 1) Main page is nothing or something unkown is set 2) Page content, with ID retrieved from ?pid= 3) List of pages <?php include('includes/db.php'); dbconnect(); if(isset($_GET['pid'])) { $id = $_GET['pid']; $sql = "SELECT body FROM cms WHERE id = '$id'"; if( !@mysql_query($sql) ) { echo("There was something wrong with the page you requested, so I'm giving up trying to regurgitate the gobble di gook"); } else { $result = mysql_query($sql); echo($result); } } if( (!$_GET['pid']) || (!$_GET['pagelist']) ) { $homesql = "SELECT body FROM cms WHERE title = 'SpaazZ Home'"; $homeresult = mysql_query($homesql) or die(mysql_error()); while( $row = mysql_fetch_assoc($homeresult) ) { $content = $row['body']; } $homecontent = stripslashes(nl2br($content)); echo($homecontent); } if( $_GET['pagelist'] ) { $sql = "SELECT * FROM cms"; $result = mysql_query($sql) or die(mysql_error()); while( $row = mysql_fetch_assoc($result) ) { $id = $row['id']; $title = $row['title']; echo("<a href='index.php?pid=$id'>$title</a><br />"); } } mysql_close(); if( isset($_GET['admin']) ) { include('includes/templates/adminlogin.tpl'); } ?> And no, I'm not getting errors or anything, it's just now working... ???
  12. .. apparently my server takes time to update... Solved.
  13. When entering data througha text box to be stored in a mySql database, how do you preserve the white space when it gets displayed back onto a page? Eg: if i post a multi-paragraphed page, how do I keep the paragraphs seperated? ???
  14. <?php session_start(); if ($_SESSION['loggedin'] != true) { header("Location: ../index.php"); } if (!isset($_POST)) { header("Location: index.php"); } if (isset($_POST['newpage'])) { include_once('../includes/db.php'); dbconnect(); $url_title = $_POST['urltitle']; $public_title = $_POST['publictitle']; $body = $_POST['pagebody']; $sql = "INSERT INTO pages (pagetitle, contenttitle, content) VALUES ($url_title, $public_title, $body)"; mysql_query($sql) or die(''.mysql_error().'<br />The query that was executed was: <br /> $sql'); mysql_close(); $_SESSION['message'] = 'New page added successfully'; echo('Click Here to go back to the Admin Page - Use FireFox and you won\'t see these messages...'); header("Location: index.php"); } ?>
  15. I feel a bit nubish asking this question, but it's been so long since I've coded PHP that I can't seem to remember anything. What I want to do is very basic. Connect to db, select rows, display them in a dynamic table that expands as needed based on number of rows in db. Below is my code. What piece am I missing to make the table work? <?php include_once('includes/db.php'); dbconnect(); $sql = "SELECT * FROM pages WHERE archived = '0'"; $reqult = mysql_query($sql) or die(mysql_error()); while( $row = mysql_fetch_array($result) ) { $id = $row['id']; $urltitle = $row['pagetitle']; $pagetitle = $row['contenttitle']; $body = $row['content']; echo('<table width="100%" border="1" cellspacing="0" cellpadding="0">'); foreach($row as ...) #is foreach what i'm looking to use? { echo(' <tr> <td>$id</td> <td>$urltitle</td> <td>$pagetitle</td> <td>$body</td> </tr> '); } echo('</table>'); mysql_close(); ?>
×
×
  • 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.