Jump to content

chicago

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Everything posted by chicago

  1. Thanks that has solved that problem but I was wondering whether yo could help me another problem it is now showing. The error message reads: Parse error: syntax error, unexpected $end in C:\wamp\www\admin.php on line 104 This is the same file I posted before plus this form: <form method="post" action=""> <table width="400" border="0" align="center" cellpadding="2" cellspacing="2"> <tr> <td>Username: </td> <td><input type="text" name="username"></td> </tr> <tr> <td>Passwd: </td> <td><input type="password" name="passwd"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="reset" value="Reset"> </td> </tr> </table> </form> <br> <br> </td> <td width="1" bgcolor="lightskyblue" valign="top"> </td> </tr></table> </body> </center> </html> Line 104 is the last line </html> any ideas would be really appreciated? Thanks
  2. This is the section of code I posted before: if (isset($_POST['username'] == '***') && ($_POST['password'] == '***')) { $_SESSION['username'] = 'login'; } There is a closing ), where did you see this error? Thanks
  3. My full code is: <?php print_r($_POST); // This will appear at the top of this page. It will contain every variable passed via a form that used the POST method. if (isset($_REQUEST['logout'])) { session_unset(); } if (isset($_POST['submitUpdate'])) { if (get_magic_quotes_gpc()) { $_POST = array_map('stripslashes',$_POST); } $fc = file_get_contents($_POST['file']); // truncate file $fw = fopen($_POST['file'], 'w+'); $text = explode("<!-- EDITABLE -->",$fc); $newText = $text[0]."<!-- EDITABLE -->".htmlentities($_POST['content'])."<!--EDITABLE ->".$text[2]; if (fwrite($fw, $newText)===FALSE) { die("Cannot write to file."); } fclose($fw); exit("<div><span class='redText'>The file has been updated. Click <a href=\"index.php\">here</a> to go back to admin page.</div>"); } if (isset($_POST['Submit'])) { if (isset($_POST['username'] == '***') && ($_POST['password'] == '***')) { $_SESSION['username'] = 'login'; } else { echo "<b>Your login details are not correct. Please login again</b>"; } } if ($_SESSION['username']=='login') { if (isset($_REQUEST['file'])) { $fc = file_get_contents($_REQUEST['file']); $text = explode("<!--EDITABLE-->",$fc); echo "<form method='post' action=''><textarea name='content'>$text[1]</textarea>"; echo "<p><input type='hidden' name='file' value='".$_REQUEST['file']."' /><input name='submitUpdate' type='submit' value='Update Page'></form>"; } else { echo "<p align='center'> <a href='example.html'>Example</a><br/> <a href='example2.html'>Example2</a><br/> <br/> <em>Click on the links above to edit the files.</em><br/> <a href='staff.php'>logout</a></p>"; } session_destroy(); ?> obviously without the indentation that you were kind enough to do for me. There is only the form after this. Can you see anything that could be making the error? Thanks again for help
  4. I have counted all the curly brackets and every one that is opened also closes, thats what I thought the problem was. Any other ideas? Thanks for replying
  5. sorry I didn't realise, I thought because I had a similar problem I could post it there obviosuly not, noted! Here is more of my code: if (isset($_POST['submitUpdate'])) { if (get_magic_quotes_gpc()) { $_POST = array_map('stripslashes',$_POST); } $fc = file_get_contents($_POST['file']); // truncate file $fw = fopen($_POST['file'], 'w+'); $text = explode("<!-- EDITABLE -->",$fc); $newText = $text[0]."<!-- EDITABLE -->".htmlentities($_POST['content'])."<!--EDITABLE ->".$text[2]; if (fwrite($fw, $newText)===FALSE) { die("Cannot write to file."); } fclose($fw); exit("<div><span class='redText'>The file has been updated. Click <a href=\"index.php\">here</a> to go back to admin page.</div>"); } if (isset($_POST['Submit'])) { if (isset($_POST['username'] == '***') && ($_POST['password'] == '***')) { //THIS LINE $_SESSION['username'] = 'login'; } else { echo "<b>Your login details are not correct. Please login again</b>"; } } Can anyone help please?
  6. Hey guys, I am getting the same error and I can't figure out why, I've double checked all my brackets and everything. It's probably just something simple but once you've been staring at it for ages you can't see very much. My code is: if (isset($_POST['Submit'])) { if (isset($_POST['username'] == '***') && ($_POST['password'] == '***')) { //THIS IS THE LINE $_SESSION['username'] = 'login'; } else { echo "<b>Your login details are not correct. Please login again</b>"; } } I've highlighted the line that the error appears on , can anybody help me?
  7. Fantastic thank you that worked!!!
  8. Anyone? Please I really don't understand why its doing it.
  9. Hi, I am using the include function to link my header and menu up to my files. My folder structure is: WWW Folder -head.html -menu.html -homepage.php Images Folder Blog Folder -index.php The head.html and menu.html have links to images kept within the images folder. homepage.php and index.php both have include functions to include the menu and header thus including the images. homepage.php works fine the images show up however blog.php links to the head and menu but does not show up the images. my include function for index.php is: <?php include ("..\menu.html"); ?> I have attached a print screen of what the index.php looks like, its obvious that its picking up the head and menu as its showing the image names but not showing the images. Can anybody help it's really confusing me? Thanks [attachment deleted by admin]
  10. The file names are head.html and menu.html not php like I stated, my mistake. It's still the same problem though can anyone help?
  11. Hi, I am trying to include my menu and header on my website. It seems to be picking up the pictures but not showing them. My code is: <?php include ("..\head.html"); ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td valign="top" align="left" width="90"> <?php include ("..\menu.html"); ?> My file structure is like this: FILE menu.php FILE head.php FOLDER blog - FILE index.php(where the code came from) FOLDER Images The menu and head files all link to the images folder, it is showing me the name of the image but just a little red cross. I hope that explains it ok. I don't knwo if i'm just missing something simple. Can anyone help?
  12. Thank you DavidAM that has solved it!!!! Much appreciated!!!
  13. This code: $sql = "SELECT * FROM php_blog_comments WHERE entry='$id' ORDER BY timestamp"; $result = mysql_query ($sql) or print ("Can't select comments from table php_blog_comments.<br />" . $sql . "<br />" . mysql_error()); while($row = mysql_fetch_array($result)) { $timestamp = date("l F d Y", $row['timestamp']); printf("<hr />"); print("<p>" . stripslashes($row['comment']) . "</p>"); printf("<p>Comment by <a href=\"%s\">%s</a> @ %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp); printf("<hr />"); } I tried to remove stripslashes($row['url']), from here and it gave me that error. Any ideas?
  14. Please can someone help with my problem: Warning: printf() [function.printf]: Too few arguments in C:\wamp\www\Blog\journal.php on line 65 The code is in my last post!!!! Please, I would really appreciate it
  15. Oh my gosh, Can you believe it I checked all the table names but didn't check the database name that was the problem. Thanks for the help guys!!! However I have another little problem I hope you can help with. $sql = "SELECT * FROM php_blog_comments WHERE entry='$id' ORDER BY timestamp"; $result = mysql_query ($sql) or print ("Can't select comments from table php_blog_comments.<br />" . $sql . "<br />" . mysql_error()); while($row = mysql_fetch_array($result)) { $timestamp = date("l F d Y", $row['timestamp']); printf("<hr />"); print("<p>" . stripslashes($row['comment']) . "</p>"); printf("<p>Comment by <a href=\"%s\">%s</a> @ %s</p>", stripslashes($row['url']), stripslashes($row['name']), $timestamp); //THIS LINE printf("<hr />"); } I want to delete the stripslashes($row['url']), from the line I have highlighted as i'm not using url anymore however when I try to do this I get the following error: Warning: printf() [function.printf]: Too few arguments in C:\wamp\www\Blog\journal.php on line 65 Line 65 is the line I have highlighted. Please can you help thanks
  16. The blog inserts fine into the php_blog table but when I try to add a comment to that blog it justs gives nothing, no error message it just inserts nothing. strange huh?
  17. Thanks for that. The comments will be placed in the php_blog_comments table which is what I have said in the code. I've triple checked the spelling to make sure I didn't just make a stupid mistake. It's puzzling, can you not see whats wrong with it? Thanks again for the help!!
  18. Hi thanks for replying. My whole code to submit the comments is: <?php if (isset($_POST['submit_comment'])) { } if (isset($_POST['submit_comment'])) { if (empty($_POST['name']) || empty($_POST['comment'])) { } $entry = htmlspecialchars(strip_tags($_POST['entry'])); $timestamp = htmlspecialchars(strip_tags($_POST['timestamp'])); $name = htmlspecialchars(strip_tags($_POST['name'])); $comment = htmlspecialchars(strip_tags($_POST['comment'])); $comment = nl2br($comment); if (!get_magic_quotes_gpc()) { $name = addslashes($name); $comment = addslashes($comment); } mysql_connect ('localhost', 'admin', 'xyz') ; mysql_select_db ('teachDirectory'); $result = mysql_query("INSERT INTO php_blog_comments (entry, timestamp, name, comment) VALUES ('$entry','$timestamp','$name','$comment')"); header("Location: journal.php?id=" . $entry); } else { die("Error: you cannot access this page directly."); } ?> I have taken out the die command like you said, your right it would scare them off, I have kept in the if statement you told me to take out just so I know where the mysql_real_escape_string() will go. I will take it out eventually. However I am new to php and I don't know how to code the mysql_real_escape_string() for it to do what I want I would appreciate the help here. My problem is that the comments don't seem to be posted themselves into he php_blog_comments table which I set up in my database, however the code is telling it to place them there. Any ideas?? I understand i'm asking for a lot but I really appreciate it
  19. Can anybody help me with this please? I have no idea why its not working??? Thanks
  20. I added a comment to one of the blog posts as a test and it worked but for some reason it saved it as an alteration to the original blog not a seperate comment so it saved it within the php_blog table not the php_blog_comments table. This is my code that adds a comment to a chosen post: <?php if (isset($_POST['submit_comment'])) { } if (isset($_POST['submit_comment'])) { if (empty($_POST['name']) || empty($_POST['comment'])) { die("You have forgotten to fill in one of the required fields! Please make sure you submit a name, e-mail address and comment."); } $entry = htmlspecialchars(strip_tags($_POST['entry'])); $timestamp = htmlspecialchars(strip_tags($_POST['timestamp'])); $name = htmlspecialchars(strip_tags($_POST['name'])); $comment = htmlspecialchars(strip_tags($_POST['comment'])); $comment = nl2br($comment); if (!get_magic_quotes_gpc()) { $name = addslashes($name); $comment = addslashes($comment); } mysql_connect ('localhost', '***', '***') ; mysql_select_db ('***'); $result = mysql_query("INSERT INTO php_blog_comments (entry, timestamp, name, comment) VALUES ('$entry','$timestamp','$name','$comment')"); header("Location: journal.php?id=" . $entry); } else { die("Error: you cannot access this page directly."); } ?> I've told it to insert it into php_blog_comments I don't understand why its not. Can you see anything that I have done wrong? Thanks for replying
  21. Hi everyone, I am trying to create a blog for a webiste I am creating and keep having a problem. I have created a file called edit_comments.php which will obviously edit comments left about the blog. The problem I am having is that when I preview this page it's just blank, no error messages nothing. This is my code: <?php mysql_connect ('localhost', '***', '***') ; mysql_select_db ('***'); if (isset($_POST['edit'])) { $name = htmlspecialchars(strip_tags($_POST['name'])); $comment = htmlspecialchars(strip_tags($_POST['comment'])); $comment = nl2br($comment); $id = (int)$_POST['id']; if (!get_magic_quotes_gpc()) { $name = addslashes($name); $comment = addslashes($comment); } $result = mysql_query("UPDATE php_blog_comments SET name='$name', comment='$comment' WHERE id='$id' LIMIT 1") or print ("Can't update comment.<br />" . $result . "<br />" . mysql_error()); if ($result != false) { print "<p>The comment has successfully been edited!</p>"; } } if(isset($_POST['delete'])) { $id = (int)$_POST['id']; $result = mysql_query("DELETE FROM php_blog_comments WHERE id='$id' LIMIT 1") or print ("Can't delete comment.<br />" . $result . "<br />" . mysql_error()); if ($result != false) { print "<p>The comment has successfully been deleted!</p>"; } } if (isset($_GET['id']) && !empty($_GET['id']) && is_numeric($_GET['id'])) { $result = mysql_query ("SELECT * FROM php_blog_comments WHERE id='$_GET[id]'") or print ("Can't select comment.<br />" . mysql_error()); while ($row = mysql_fetch_array($result)) { $old_name = stripslashes($row['name']); $old_comment = stripslashes($row['comment']); $old_comment = str_replace('<br />', '', $old_comment); } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><input type="hidden" name="id" id="id" value="<?php echo $_GET['id']; ?>"> <strong><label for="name">Name:</label></strong> <input type="text" name="name" id="name" size="40" value="<?php echo $old_name; ?>" /></p> <p><strong><label for="comment">Comment:<label></strong><br /> <textarea cols="80" rows="20" name="comment" id="comment"><?php echo $old_comment; ?></textarea></p> <p><input type="submit" name="edit" id="edit" value="Save Changes"> <input type="submit" name="delete" id="delete" value="Delete Comment"> <input type="submit" value="Never Mind"></p> </form> <?php } else { $result = mysql_query("SELECT entry AS get_group FROM php_blog_comments GROUP BY get_group DESC LIMIT 10") or print ("Can't select comments.<br />" . $result . "<br />" . mysql_error()); while($row = mysql_fetch_array($result)) { $get_group = $row['get_group']; print "<p>"; $result2 = mysql_query("SELECT timestamp, title FROM php_blog WHERE id='$get_group'"); while($row2 = mysql_fetch_array($result2)) { $date = date("l F d Y",$row2['timestamp']); $title = stripslashes($row2['title']); print "<strong>" . $date . " - " . $title . "</strong><br />"; } $result3 = mysql_query("SELECT * FROM php_blog_comments WHERE entry='$get_group' ORDER BY timestamp DESC"); while($row3 = mysql_fetch_array($result3)) { $id = $row3['id']; $name = stripslashes($row3['name']); $comment = stripslashes($row3['comment']); $date = date("l F d Y",$row3['timestamp']); if (strlen($comment) > 75 || strstr($comment, "<br />") || strstr($comment, "\n")) { $comment = substr($comment,0,75) . "..."; $comment = str_replace("<br />", "", $comment); $comment = str_replace("\n", " ", $comment); } print "<a href=\"editcomments.php?id=" . $id . "\">" . $comment . "</a><br />Comment by " . $name . " @ " . $date; print "</p>"; } } } mysql_close(); ?> Sorry it's a bit long. If anybody could help me understand what's happening I would really appreciate it thanks!!!
  22. This isn't all the code it connects to the database before this section of code <?php ob_start(); $host="localhost"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="database"; // Database name $tbl_name="blog_users"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); Is there any way to solve the problem?
  23. Hi guys, I'm new to forums so hopefully someone can help me. I keep getting the following error: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\Blog2\checklogin.php on line 27 My code is: // Define $blog_user_name and $blog_user_password $blog_user_name=$_POST['blog_user_name']; $blog_user_password=$_POST['blog_user_password']; // To protect MySQL injection (more detail about MySQL injection) $blog_user_name = stripslashes($blog_user_name); $blog_user_password = stripslashes($blog_user_password); $blog_user_name = mysql_real_escape_string($blog_user_name); $blog_user_password = mysql_real_escape_string($blog_user_password); $sql="SELECT * FROM $tbl_name WHERE username='$blog_user_name' and password='$blog_user_password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); //THIS IS LINE 27 // If result matched $blog_user_name and $blog_user_password, table row must be 1 row if($count==1){ // Register $blog_user_name, $blog_user_password and redirect to file "index.php" session_register("blog_user_name"); session_register("blog_user_password"); header("location:index.php"); } else { echo "Wrong Username or Password"; } ob_end_flush(); Please can someone help I have know idea what the problem could be. Thanks.
×
×
  • 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.