Jump to content

Xager

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Xager's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have been getting this error: Warning: Cannot modify header information - headers already sent in /home/xager/public_html/srag/dev/index2.php on line 53 (exact copy and past) I have searched, for 3 days, trying to get answers to this. I have check for blank spaces, checked every single thing that I can find, tested, checked again, deleted, started again... and on and on. So I'm tearing my hair out at this error. I do not know PHP all that well. I am using Dreamweaver CS4 and have created quite a few other websites in the same way, but recently this one is just messing up. The follow is the page that I am working on. I will also have about 9 other pages with pretty much the same setup. <?php virtual('/Connections/srag_conn.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE home SET header=%s, content=%s WHERE id=%s", GetSQLValueString($_POST['header'], "text"), GetSQLValueString($_POST['content'], "text"), GetSQLValueString($_POST['id'], "int")); mysql_select_db($database_srag_conn, $srag_conn); $Result1 = mysql_query($updateSQL, $srag_conn) or die(mysql_error()); $updateGoTo = "success.html"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } mysql_select_db($database_srag_conn, $srag_conn); $query_Recordset1 = "SELECT * FROM home"; $Recordset1 = mysql_query($query_Recordset1, $srag_conn) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <!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> <title>Stanthorpe Regional Art Gallery</title> <link href="../style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="spar"></div> <div id="home"><a href="index.php">HOME</a></div> <div id="exhibitions"><a href="exhibitions.php">EXHIBITIONS</a></div> <div id="collection"><a href="collection.php">COLLECTION</a></div> <div id="events"><a href="events.php">EVENTS</a></div> <div id="public"><a href="public.php">PUBLIC<br /> PROGRAMS</a></div> <div id="membership"><a href="membership.php">MEMBERSHIP</a></div> <div id="contact"><a href="contact.php">CONTACT</a></div> <div id="homebb"></div> <div id="content"> <div id="logo"></div> <div id="container"> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Header:</td> <td><input type="text" name="header" value="<?php echo ($row_Recordset1['header']); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Content:</td> <td><input type="text" name="content" value="<?php echo ($row_Recordset1['content']); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Update record" /></td> </tr> </table> <input type="hidden" name="MM_update" value="form1" /> <input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>" /> </form> <p> </p> </div> </div> </body> </html> <?php mysql_free_result($Recordset1); ?> Any help is greatly appreciated!
  2. Ok that works, I dont know how I did it but I didnt type it out properly or something. But it's working fine now, thanks. Learnt heaps . Regards, Xager
  3. Excellent. the only problem is that it doenst have the first two as "expanded" the code is that they all have the display:none; instead of the first two having display:relative;
  4. ok I got this: 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 'ORDER BY date DESC' at line 1 thanks for your help mate really appreciate it.
  5. awesome! I am pretty sure I understand that but I can't really figure out what the problem is, I get this: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xager/public_html/V2/test2.php on line 11 It's probably easy but I can't figure it out.
  6. I did get it working the the way I wanted it finally. The only this is there must be a better way to do it, because I don't know that much PHP I haven't got a clue how so I will post my code and hopefully get some ideas on how to clean it up and condense it down a bit. <?php include 'mysql_connect.php'; $from = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM news_posts"),0); $idone = $from; $idtwo = $from - 1; $idthree = $from - 2; $idfour = $from - 3; $idfive = $from - 4; $idonesql = mysql_query("SELECT id, title, newstype, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts WHERE id=$idone"); $commone = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM comments WHERE nid=$idone"),0); while($row = mysql_fetch_array($idonesql)){ echo "<img src=d.gif name=img$row[id] width=9 height=9 border=0> <a href='javascript:voide(0)' onClick=shoh($row[id]);>$row[title]</a> | $row[newstype]<br /><div style=display:relative; id=$row[id]>$row[post]<br />$row[author] | $row[sd] | <a href=comment.php?id=$idone>Comment [$commone]</a></div><br /><hr width=100% /><br />"; } $idtwosql = mysql_query("SELECT id, title, newstype, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts WHERE id=$idtwo"); $commtwo = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM comments WHERE nid=$idtwo"),0); while($row = mysql_fetch_array($idtwosql)){ echo "<img src=d.gif name=img$row[id] width=9 height=9 border=0> <a href=javascript:voide(0) onClick=shoh($row[id]);>$row[title]</a> | $row[newstype]<br /><div style=display:relative; id=$row[id]>$row[post]<br />$row[author] | $row[sd] | <a href=comment.php?id=$idtwo>Comment [$commtwo]</a></div><br /><hr width=100% /><br />"; } $idthreesql = mysql_query("SELECT id, title, newstype, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts WHERE id=$idthree"); $commthree = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM comments WHERE nid=$idthree"),0); while($row = mysql_fetch_array($idthreesql)){ echo "<img src=u.gif name=img$row[id] width=9 height=9 border=0> <a href=javascript:voide(0) onClick=shoh($row[id]);>$row[title]</a> | $row[newstype]<br /><div style=display:none; id=$row[id]>$row[post]<br />$row[author] | $row[sd] | <a href=comment.php?id=$idthree>Comment [$commthree]</a></div><br /><hr width=100% /><br />"; } $idfoursql = mysql_query("SELECT id, title, newstype, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts WHERE id=$idfour"); $commfour = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM comments WHERE nid=$idfour"),0); while($row = mysql_fetch_array($idfoursql)){ echo "<img src=u.gif name=img$row[id] width=9 height=9 border=0> <a href=javascript:voide(0) onClick=shoh($row[id]);>$row[title]</a> | $row[newstype]<br /><div style=display:none; id=$row[id]>$row[post]<br />$row[author] | $row[sd] | <a href=comment.php?id=$idfour>Comment [$commfour]</a></div><br /><hr width=100% /><br />"; } $idfivesql = mysql_query("SELECT id, title, newstype, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts WHERE id=$idfive"); $commfive = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM comments WHERE nid=$idfive"),0); while($row = mysql_fetch_array($idfivesql)){ echo "<img src=u.gif name=img$row[id] width=9 height=9 border=0> <a href=javascript:voide(0) onClick=shoh($row[id]);>$row[title]</a> | $row[newstype]<br /><div style=display:none; id=$row[id]>$row[post]<br />$row[author] | $row[sd] | <a href=comment.php?id=$idfive>Comment [$commfive]</a></div><br /><hr width=100% /><br />"; } ?> So, there it is, if anyone can let me know if there is an easier way to do it that would be great. There is a working version of this on my website @ www.xager.net/V2/test.php Cheers, Xager
  7. Thats not really what I meant. That website is mine so I already have the Javascript working, what I need is some PHP to display 5 posts. Not a script to dispaly 5 posts through LIMITs and ORDER, 5 posts so that I may change the way they look independantly. Sorry for my pretty crappy description.
  8. check out www.xager.net/V2/index.php which is what i want to do, excepts that instead of having them all minimized I want to have the top 2 expanded and then the next 3 minimized. Javascript does the maximize and minimize and PHP is pulling the information out of the database.
  9. thanks for the speedy responce, but... I don't know enough PHP to really do this, which is why I am here, I am learning but not enough yet. So, this is what I have, it's basic at the moment but I am pretty sure its not going to do what I want. <?php include 'mysql_connect.php'; $sql = mysql_query("SELECT * FROM news_posts LIMIT 5 ORDER BY id DESC"); while($row = mysql_fetch_array($sql)){ echo "$row[title]</a> | $row[newstype]<br />$row[post]<br />$row[author] | $row[sd]<br /><hr width=100% /><br />"; } ?> I probably should have explained this a bit more so: What I want is to have the 5 posts, the top 2 will be "expanded" so that you can view all information contained, then the next 3 I want to be "minimized" so that all you see is the title with has a little + or - for coolness and the newstype. So, in that script that was mentioned in the above post it would display the code the same for all 5 instead of haveing seperate code for the "expanding" and "minimizing" sets. Once again I hope this makes sense. I don't really know how to explain things much better. Cheers, Xager
  10. First: I don't know that much PHP so please excuse my ignorance. I have been doing up a website which will, among other things, display news that I input into the MYSQL database. I have a working version of this where it just displays 5 posts per page in descending order (the latest at the top of the page) with the page numbering underneath them. Now what I wan't to do is just dispaly the latest 5 posts on the page but, I want to dispaly them so that I can put in a Javascript function to maxamize and minimize each post by clicking on the title. So, I have, ID, Title, Newstype, Author, Post, Date. In my mind I see this as display each of these using the COUNT(*) thing and just subtracting 1, 2, 3, 4 to get the 5 posts I want. I just don't know how to do it. I hope that made sense I almost don't understand it myself ??? Thanks for any help Regards, Xager
  11. Ok, maybe I wasnt quite clear. when I input new items i use my addnews.php form with Title (text field), Author (text field) and Content (text field). What I would like to do is insert a drop down menu, as in <select...><option>Option1</option><option>Option2</option></select>. How do I go about this with coherence with my script from previous post. Thanks for any replies. Regards, Xager
  12. I received a message today and wanted to reply to it but go this: An Error Has Occurred! You are not allowed to send personal messages. I only have 3, now 4, posts, is that the reast I cant send messages? protection against bots or something? or is there a deeper more evil problem?
  13. I have a news posting system on my website, its pretty basic but its all I need. What I have as fields are id, title, author, post, date. I have them all displaying properly as I want them, but now what I want to do is add an options (drop down menu) field aswell. Now I have added newstype ENUM 'field1','field2','field3','field4' NOT NULL DEFAULT field1 to my news database and I want to do is add a dropdown to my addnews.php form so that I can input these fields. addnews.php: <?php if (isset($_POST['submitted'])) { include ('mysql_connect.php'); if (empty($_POST['title'])) { echo '<p><font color="red">You need to enter a title.</font></p>'; } else { $title = $_POST['title']; } if (empty($_POST['name'])) { echo '<p><font color="red">You need to enter a name.</font></p>'; } else { $name = $_POST['name']; } if (empty($_POST['message'])) { echo '<p><font color="red">You need to enter a message.</font></p>'; } else { $message = $_POST['message']; } if ($title && $name && $message) { $query = "INSERT INTO news_posts (title, author, post, date) VALUES ('$title', '$name', '$message', NOW())"; $result = @mysql_query($query); if ($result) { echo '<p><font color="red">News was added!</font></p>'; } else { echo '<font color="red"><p>News could not be added! Please try again.</p></font>'; } } else { echo '<p><font color="red">Please fill in the appropriate information</font></p>'; } } ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <p><b>News Title :</b><br /> <input type="input" name="title" size="25" maxlength="60" value="<?php if(isset($_POST['title'])) echo $_POST['title']; ?>" /></p> <p><b>Name :</b><br /> <input type="input" name="name" size="15" maxlength="35" value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" /></p> <p><b>Message :</b><br /> <textarea rows="7" cols="55" name="message"><?php if(isset($_POST['message'])) echo $_POST['message']; ?></textarea></p> <p><input type="submit" name="submit" value="Add News" /></p> <input type="hidden" name="submitted" value="TRUE" /></p> </form> Any ideas on how / where to add this said drop down field? I have never done one before and dont know enough PHP to figure out how. Also, I have a Edit form. I also would need some help with getting it up and running with a drop down field. edit_news.php: <?php include('mysql_connect.php'); if ((isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { $id = $_POST['id']; } else { echo 'Please choose a news post to edit.'; exit(); } if (isset($_POST['submitted'])) { $errors = array(); if (empty($_POST['title'])) { $errors[] = 'You forgot to enter a title.'; } else { $title = $_POST['title']; } if (empty($_POST['name'])) { $errors[] = 'You forgot to enter an author.'; } else { $name = $_POST['name']; } if (empty($_POST['message'])) { $errors[] = 'You forgot to enter a message'; } else { $message = $_POST['message']; } if (empty($errors)) { $query = "UPDATE news_posts SET title='$title', author='$name', post='$message' WHERE id=$id"; $result = mysql_query($query); if ($result) { echo "News Post Has Been Updated!"; } else { echo "News post could not be updated."; } } else { echo 'News post could not be updated for the following reasons -<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } } } else { $query = "SELECT title, author, post, id FROM news_posts WHERE id=$id"; $result = mysql_query($query); $num = mysql_num_rows($result); $row = mysql_fetch_array ($result, MYSQL_NUM); $title = $row['0']; $name = $row['1']; $message = $row['2']; if ($num == 1) { echo '<h3>Edit News Post</h3> <form action="?id=edit_news&num='.$id.'" method="post"> <p><b>News Title :</b> <input type="text" name="title" size="25" maxlength="255" value="'.$title.'" /></p> <p><b>Name :</b> <input type="text" name="name" size="15" maxlength="255" value="'.$name.'" /></p> <p>Message :</b> <br /><textarea rows="5" cols="40" name="message">'.$message.'</textarea></p> <p><input type="submit" name="submit" value="Submit" /></p> <input type="hidden" name="submitted" value="TRUE" /></p> <input type="hidden" name="id" value="'.$id.'" />'; } else { echo 'News post could not be edited, please try again.'; } } ?> My website is www.xager.net to see a working version of what i have now. Thank you very much for any responces. Looking forward to your input. Regards, Xager
  14. OK, I did what you said and this is what i get Array ( [0] => 1 [1] => [2] => [3] => [4] => 2007-08-09 [5] => ) 1 Array ( [0] => 2 [1] => [2] => [3] => [4] => 2007-08-09 [5] => ) 1 I understand that only the Date is showing, I just dont know how to fix it. Any ideas?
  15. Sorry, but I dont know much PHP at the moment. I am trying to put a basic News Section into my website, I found a tutorial for it <a href="http://www.beginnersphp.co.uk/news.php">HERE</a>. I followed it as best I could and got almost what I wanted. I just have one problem, well, I think its just one problem. When loading my index.php to display my News items it doesnt all show up, only the author and submitted shows, there are spaces for the Title Descriptions and URL but no text shows up. Here is my code: index.php <?php include("config.php"); //this is our SQL query , note we are ordering by the submitted date //and setting a limit of ten items $query = "SELECT * FROM news ORDER BY submitted DESC LIMIT 10"; //execute the query $result = mysql_query($query); //start creating our table echo ("<table border='0' width='90%'>"); //loop through rows in the database while ($rows = mysql_fetch_row($result)) { //in the first row we display the title ($rows[1]) and the author $rows[3] echo ("<tr bgcolor='violet'><td>$rows[1]</td><td>author : $rows[3]</td></tr>"); //in the next row we display the description which is $rows[2] echo ("<tr><td colspan='2' bgcolor='lavender'>$rows[2]</td></tr>"); //finally we display the url which is rows[5] and the submitted date which is rows[4] echo ("<tr bgcolor='violet'><td><a href='$rows[5]'>$rows[5]</a></td><td>Submitted on : $rows[4]</td></tr>"); } //finish or table echo "</table>"; ?> and add.php (news item submission form) <?php include("config.php"); //create or query inserting the appropriate values into the mysql //table $query = "INSERT INTO news(title , description ,author , submitted , url) VALUES('$title','$desc','$author', now(),'$url')"; //execute query and store result as variable $result = mysql_query($query); //displays a message , you could redirect back to the form //instead , if you wished echo ("news item entered"); ?> <form action ="add.php" method = "post"> <table> <tr><td>Title</td><td><input type="text" name="title"></td></tr> <tr><td>Author</td><td><input type="text" name="author"></td></tr> <tr><td>Description</td><td><textarea name="desc" rows="5" cols="50" wrap="VIRTUAL"></textarea></td></tr> <tr><td>URL</td><td><input type="text" name="url"></td></tr> <tr><td><input type="submit"></td><td><input type="reset"></td></tr> </table> </form> thanks for any answers. Regards, Xager.
×
×
  • 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.