Jump to content

woodplease

Members
  • Posts

    121
  • Joined

  • Last visited

    Never

Everything posted by woodplease

  1. well i just checked again, and it definately is
  2. thats what i've done, the first two lines of the page are <?php session_start();
  3. i've looked through that thread, and it the suggestions dont solve the problem
  4. i keep getting this error whenever i load my page Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\wiki\index.php:1) in C:\xampp\htdocs\wiki\index.php on line 2 <?php session_start(); include "includes/dbconnect.php"; include "includes/functions.php"; forum_connect(); ?> <!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> <link rel="stylesheet" type="text/css" href="../style.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Wiki</title></head> <body id="page1"> <div id="header"> <div class="container"> <div class="logo"> <a href="index.html"><img src="images/logo.gif" alt="logo" /></a> </div> i've made sure that session_start() is at the very top, and there are no rogue spaces or breaks , so i dont know why i'm getting the error. any ideas? thanks
  5. thanks, but i have a problem with the (php) page that displays in the div. There is a form in the php page that when submitted, reloads the php page, and runs code to insert the form data into a table. the problem is that it is reloading the page with the ajax on, therefore the php page is no longer loaded in the div resulting in the code not running. the code on the form (of the php page) that reloads the page is <form name="add_section" method="post" action="<?php echo $_SERVER['../PHP_SELF']; ?>"> when the page reloads, its uses if (isset($_POST['new_section'])) { if (!$section_title ) { die('You did not complete all of the required fields<br/><a href="./new_section.php">Back</a>'); } $query = "INSERT INTO section_main (section_title) VALUES ('$section_title')"; $add_section = mysql_query($query) or die ('could not add new section');
  6. There are no error messages. when an ajax link is clicked, it loads a (php) page into the div tag. This displays. There is a form in the php page that when submitted, reloads the php page, and runs code to insert the form data into a table. the problem is that it is reloadiung the page with the ajax on, therefore the php page is no longer loaded in the div resulting in the code not running
  7. i've tried that, but now the php on the page it displays in the div doesnt work. The php reloads the (php) page to INSERT data into a table, using if($_POST ), but it reloads the whole page, not just the div.
  8. l have a script i got of dynamic drive that loads another page inside a div tag. This works. the page that is loading contains code than when run, reloads that php page to insert data into a database. The problem is that it just reloads the entire page and doesnt enter the data into the database. The main page <div id='fcontrol'><table border='1' class ='tstyle'><tr height ='700'><td valign='top' class='ssbg' width='120'><div id='menu'><a href='javascript:ajaxpage("new_section.php", "contentarea");'>Add new section</a><br/><br/><a href='javascript:ajaxpage("new_sub_section.php", "contentarea");'>Add new section to forum</a><br/><br/><a href='index.php'>Back to forum</a><br/><br/></div></td><td class='tcontrol' width='700' valign='top'><center><div id='contentarea'>Control Panel</div></center></td></tr></table></div></div> the page inside the div if (isset($_POST['new_section'])) { if (!$section_title ) {die('You did not complete all of the required fields<br/><a href="./new_section.php">Back</a>');}$query = "INSERT INTO section_main (section_title) VALUES ('$section_title')";$add_section = mysql_query($query) or die ('could not add new section');?><h1>section added</h1><?php}else{?><form name="add_section" method="post" action="<?php echo $_SERVER['../PHP_SELF']; ?>"><table><tr><td>Section Name</td><td><input type="text" name="section_title" maxlength="200" /></td></tr><tr><td></td><td><input type="submit" name="new_section" value="Add Section"/></td></tr></table></form><?php}?> the javascript var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)var loadedobjects=""var rootdomain="http://"+window.location.hostnamevar bustcacheparameter=""function ajaxpage(url, containerid){var page_request = falseif (window.XMLHttpRequest) // if Mozilla, Safari etcpage_request = new XMLHttpRequest()else if (window.ActiveXObject){ // if IEtry {page_request = new ActiveXObject("Msxml2.XMLHTTP")} catch (e){try{page_request = new ActiveXObject("Microsoft.XMLHTTP")}catch (e){}}}elsereturn falsepage_request.onreadystatechange=function(){loadpage(page_request, containerid)}if (bustcachevar) //if bust caching of external pagebustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()page_request.open('GET', url+bustcacheparameter, true)page_request.send(null)}function loadpage(page_request, containerid){if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))document.getElementById(containerid).innerHTML=page_request.responseText}function loadobjs(){if (!document.getElementById)returnfor (i=0; i<arguments.length; i++){var file=arguments[i]var fileref=""if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceedingif (file.indexOf(".js")!=-1){ //If object is a js filefileref=document.createElement('script')fileref.setAttribute("type","text/javascript");fileref.setAttribute("src", file);}else if (file.indexOf(".css")!=-1){ //If object is a css filefileref=document.createElement("link")fileref.setAttribute("rel", "stylesheet");fileref.setAttribute("type", "text/css");fileref.setAttribute("href", file);}}if (fileref!=""){document.getElementsByTagName("head").item(0).appendChild(fileref)loadedobjects+=file+" " //Remember this object as being already added to page}}} I've included all the code related to the problem. i know its a lot, but i wanted to give as much info as possible
  9. i've tried that, but it doesnt make any difference
  10. i've done that, but it had no effect. i think its to do with the " and ' i've used, but i dont know why.
  11. i'm not sure whether this should be in this section or the ajax section. i'm trying to echo out an ajax script so that a page loads in a div tag after a link is clicked in the menu. Without the "echo", it works fine, but as soon as i include it within the "echo", it stops working. Any help would be great else echo" <div id='fcontrol'> <table border='1' class ='tstyle'> <tr height ='700'><td valign='top' class='ssbg' width='120'><div id='menu'> <a href='javascript:ajaxpage(''new_section.php'', ''contentarea'');'>Add new section</a><br/><br/> <a href='javascript:ajaxpage('new_sub_section.php', 'contentarea');'>Add new section to forum</a><br/><br/><a href='index.php'>Back to forum</a><br/><br/></div></td><td class='tcontrol' width='700' valign='top'> <center><div id='contentarea'>Control Panel</div></center></td></tr> </table></div> </div> "; ?>
  12. how can i set a session to expire after a set amount of time, say 1 hour. i'm using the following code to create my session, but i dont know what i need to add to make it expire $_SESSION['pageviewsid'.$id] = $new; $new is the result from a calculation and $id is the page id from the URL using $_GET
  13. yes, it is at the beginning of the page
  14. i've got a piece of code, which acts as a page view counter by updating a field in a table everytime the page is loaded. Also, a session is created containing the current number of page views. This works except for the fact that everytime the page is refreshed, the counter is updated. To solve this i added" if (!isset ", to see if the session exists. if it does, it does not run the code, but if it doesnt exist, then it does. However, when i added the "if (!isset"... , the code stops working, and nothing gets updated if (!isset($_SESSION['pageviews'])){ $count = mysql_query("SELECT * FROM topic WHERE topic_id =" .$id) or die("Select Error3 :" . mysql_error()); $current = mysql_fetch_assoc($count); $view = $current['views']; $new = $view + 1; $update = mysql_query("UPDATE topic SET views =" .$new. " WHERE topic_id =" .$id) or die("Select Error3 :" . mysql_error()); $_SESSION['pageviews'] = $new; } Any ideas on whats wrong will be great.
  15. which part of the query are talking about?
  16. right, i've run the sql through phpmyadmin, and it seems fine, as it didnt give any errors. i've also changed it so that its mysql_fetch_assoc(), but still nothing is being echoed. I've also included the LIMIT constraint. Still nothing is being echoed. i'm not sure whether or not i am echoing out the right thing ($latest['post.date']), as i want to echo out the most rescent date. Alss, the date is stored as integers, and converted into date format afterwards My code currently looks like this: $join =mysql_query("SELECT topic.*, post.* FROM topic LEFT JOIN post ON topic.section_sub_id=post.section_sub_id WHERE post.section_sub_id = " .$row2['section_sub_id']. " ORDER BY topic.date LIMIT 1") or die("Select Error :" . mysql_error()); $latest= mysql_fetch_assoc($join); echo $latest['post.date'];
  17. i have two tables, and i want to display data from the most recent entry of the two(i.e. display just one entry). i'm joining together 2 tables so that i can get this entry.Both tables contain the date, so i'm ordering the results of the query so that the most recent comes first. My tables are: TOPIC topic_id topic _name section_sub_id date POST post_id post_name section_sub_id date I'm using the following code to get the last result, but nothing is being echoed $join =mysql_query("SELECT topic.*, post.* FROM topic LEFT JOIN post ON topic.section_sub_id=post.section_sub_id WHERE post.section_sub_id = " .$row2['section_sub_id']. " ORDER BY topic.date") or die("Select Error :" . mysql_error()); $latest= mysql_fetch_row($join); echo $latest['post.date']; i'm not sure if there is something wrong with the sql, or with the php. ANy help would be great
  18. woodplease

    joins

    i think this is in the right section. i have two table, each with a date field, and i'm trying to join them so that i can echo out the most rescent date of the two tables. i have some code but i'm not sure if the sql is correct, as nothing is being displayed. $join =mysql_query("SELECT topic.section_sub_id, topic.date, post.section_sub_id, post.date FROM topic LEFT JOIN post ON topic.section_sub_id=post.section_sub_id WHERE post.section_sub_id = " .$row2['section_sub_id']. " ORDER BY topic.date") or die("Select Error :" . mysql_error()); $latest= mysql_fetch_assoc($join); echo $latest['post.date']; my tables are TOPIC topic_id topic _name section_sub_id date POST post_id post_name section_sub_id date any help would be great
  19. i'm trying to create a page whereby a user clicks a link from a menu on the side, and the main content of the page changes to content relating to the link, without leaving that page. i know you can do this using html frames, but as frames are rarely used anymore, i wanted to use php instead. Does anyone know how i could approach this? Thanks
  20. none of the table names are capitalized though
  21. i'm trying to get the username of the last person to enter something into a database table,and display it an html table. the problem is, the query is failing, and i get the error "Table 'forum.posts' doesn't exist". if in the error message "forum" means the name of the database, and "posts" the name of the table, there is something wrong, as they both exist. the code i'm using is below $list = "SELECT * FROM section_main ORDER BY section_title"; $result = mysql_query($list) or die ("Query failed"); $numofrows = mysql_num_rows($result); for($j = 0; $j < $numofrows; $j++) { $row = mysql_fetch_array($result); echo "<tr><th>". $row['section_title']."</th></tr>"; $query2 = "SELECT * FROM section_sub WHERE section_id = '".$row['section_id']."' ORDER BY section_sub_title"; $result2 = mysql_query($query2) or die("Select Error :" . mysql_error()); $numofrows2 = mysql_num_rows($result2); for($i = 0; $i<$numofrows2; $i++){ $row2 = mysql_fetch_array($result2); echo "<tr><td><a href='display_forum.php?id={$row2[section_sub_id]}'>".stripslashes($row2[section_sub_title])."</a></td><td>"; $new = mysql_query("Select * FROM posts WHERE section_sub_id = '".$row2['section_sub_id'] . " ' ") or die ("Select Error :" . mysql_error()); //this is where the error message is from $lastpost = mysql_fetch_assoc($new); echo $lastpost['username']; echo"</td></tr>"; } } i've checked that the names of the tables and fields in the queries are correct, but i cant think of anything else that might be wrong. any help would be great.
  22. i'm trying to update a value in my table using the UPDATE command, but i'm getting 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 ''bob1234' at line 1" <?php session_start(); include "includes/dbconnect.php"; forum_connect(); $b = time (); $d = date("Y-m-d",$b); $s = time (); $t = date("G:i:s",$s); $query = "UPDATE users SET last_visit_date = '$d', last_visit_time = '$t' WHERE username = '".$_SESSION['user']; $result= mysql_query($query) or die("Select Error :" . mysql_error()); header("Location: logout2.php"); ?> i've included all the code so you can see what is going on. bob1234(from the error) is the value stored in the session. Any help on this would be great
  23. thanks, it works now. i'll have a look at using session data instead then to make it more secure
×
×
  • 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.