Jump to content

warrens0017

Members
  • Content count

    15
  • Joined

  • Last visited

Community Reputation

0 Neutral

About warrens0017

  • Rank
    Newbie
  1. warrens0017

    Getting information from Database

    I was able to figure it out and also prevent SQL injection.
  2. warrens0017

    Getting information from Database

    Hello everyone, I am running into an issue now to where I am trying to get information from a database but it is only happening when there is an apostrophe in the text. Meaning things, getting the data from the database, there is a word with an apostrophe in it. I get all the information from the start up to the point where the apostrophe is at. For example: The cat can't jump over water. What I will get is this: The can can Then I don't get the rest of my data. Here is the code I am dealing with. Any help would be great. $id = $_POST['id']; $title = $_POST['title']; $writer = $_POST['writer']; $description = $_POST['description']; $date_created = $_POST['date_created']; $message = $_POST['message']; echo "By: ".$writer; echo "Title: ".$title; echo "Description: ".$description; echo "Message: ".nl2br($message);
  3. warrens0017

    session_start(): cannot send session cache limiter

    It had to be BOM. I just deleted the file and recreated it with using just work and then copied and pasted it into a bran new accedit.php page. IDK why my editors were not able to detect the BOM but that was is. Thank you all for the help.
  4. warrens0017

    session_start(): cannot send session cache limiter

    I used Visual Studios, NotePad++, Sublime Text; All of them show that there is no UTF-8 BOMs.
  5. warrens0017

    session_start(): cannot send session cache limiter

    I just verified that all the inc files do NOT have the session_start(). Yes this is at the VERY TOP before all HTML tags. Yes there is no line break.
  6. Good day everyone, I am running into this error: Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/.../accedit.php:1) in /home/.../accedit.php:2"; i have looked it up but all I am getting is there is white space that is causing this issue. This is the top part of this code: <?php session_start(); include '../inc/inc.php'; ?> Here is the inc.php: <?php include "../inc/dbh.php"; include '../inc/header.php'; include '../inc/bg_img_page.php'; include '../inc/nav.php'; include 'info_get.php'; include 'info_set.php'; include 'info_edit.php'; include 'info_view.php';
  7. Hi everyone, Have been working with video backgrounds and everything is going great. I have surfed the web and I have been trying to find out how to display an image after a video plays. I know how I can do a poster image before a video plays, I want a poster image to be displayed after the video is done. Now I don't know where I need to post this so I figure I start here. I will post my code down below so you can take a look at what I already have. Thanks in advance! <video onloadstart='this.volume=0.3' id='bg-video-index' onclick='playVideo' autoplay> <source src='media/bg-video/bg-video.mp4' type='video/mp4'> Your browser does not support HTML5 video. </video> <script src="text/javascript"> function playVideo(){ var video = document.getElementById('bg-video-index'); video.play(); video.addEventListener('ended',function(){ window.location = 'media/images/bg/logo.png'; }); } </script>
  8. Hi everyone, I need a little help with trying to figure out what I need to do. I am writing an IF statement that allowed only certain users can see. So what I am trying to do, in my DB i have it created that if you are going to have certain access, the value in the DB is set to '1' for true. What I need help with is seeing how I can write and IF statement that reads that value and allows the user to see it. This is the current code I have: <?php if (isset($_SESSION['id'])) { echo "Welcome"; } else { echo "You not logged in or don't have access."; } ?> With this code, anyone that logs in will be able to see it. What I want is another line of code that allows those with the value of '1' in the DB to see it. I have tried many different ways of seeing if I can get it to work but it never does. It either always returned the value TRUE and reads the code or the value is FALSE; even if when I am login, the value turn FALSE. So if anyone can give me just a quick moment of their time, that would be great. NOTE: My DB Connection is in a header.
  9. warrens0017

    Warning: Cannot modify header information

    Ahhhh....I see it. I had to move around the <form> before the getNote().
  10. warrens0017

    Warning: Cannot modify header information

    <?php if (isset($_SESSION['id'])) { echo "<table id='Table_note'>"; echo "<tr class='noteTable'>"; echo "<th>Notes</th>"; echo "<th></th></tr>"; getNote($conn); echo "</table><br>"; echo "<form method='POST' action='".setNote($conn)."'> <input type='hidden' name='id' value='".$_SESSION['id']."'> <input type='hidden' name='date' value='".date('Y-m-d')."'> <textarea name='note'></textarea><br> <button class='button-YT' type='submit' name='NoteSubmit'>Sent Note</button> </form>"; } else { echo "<p>You Need to Login</p>"; } ?> This is where the setNote() and getNote() is placed.
  11. warrens0017

    Warning: Cannot modify header information

    See now I understand that but I have something very similar to the code that i wrote. BUT, with the other code that is not different in anyway, I can submit a text to the database, and have it come write back out without any errors. I did find out that with the code above that I can send one thing to the database and get it back without any issues, it only when I am trying to send more information to the database that I get the error. And that is where I am at and I am confused. That a very similar code work but not this one.
  12. warrens0017

    Warning: Cannot modify header information

    Hi, I am having an issue with a warning that keeps popping up. I have edited the line it is saying but still getting the error. Warning: Cannot modify header information - headers already sent by (output started at /Pages/Forums/comments.php:227) in /Pages/Forums/comments.php on line 88 Here are the two lines that the warning is saying function setNote($conn) { if (isset($_POST['NoteSubmit'])) { $id = mysqli_real_escape_string($conn, $_POST['id']); $date = mysqli_real_escape_string($conn, $_POST['date']); $note = mysqli_real_escape_string($conn, $_POST['note']); $sql = "INSERT INTO note (id, date, note) VALUES ('$id', '$date', '$note')"; $result = mysqli_query($conn, $sql); header("Location: /Pages/Profile.php"); //This line has the error - LINE 88 } } And the other function getNote($conn) { $id = $_SESSION['id']; $sql = "SELECT * FROM note WHERE id='$id'"; $result = mysqli_query($conn, $sql); while ($row = $result->fetch_assoc()) { echo "<div class='comment-box'><p><b>"; echo "Note: </b><br>"; echo nl2br($row['note']); echo "</p></div> <form class='delete-form' method='POST' action='".deleteNote($conn)."'> <input type='hidden' name='nid' value='".$row['nid']."'> <button type='submit' name='deleteNote'>Delete</button> </form>"; //This line has the error - LINE 227 } } Now after I refresh the page, I see what i typed. Hope someone has and answer. Thanks!
  13. warrens0017

    PHP Error - NOTICE: Undefined index

    Okay one more thing and I should be good. I got all that fixed and worked out, but now I am trying to create a login and I am getting this error: Warning: mysqli_fetch_assoc() expects parameter 1 to be resource, boolean given in Here is the code that I am working with: login.php <?php include 'dbh.php'; $uid = $_POST['uid']; $pwd = $_POST['pwd']; $sql = "SELECT * FROM username WHERE uid='$uid' AND pwd'$pwd'"; $result = mysqli_query($conn, $sql); if (!$row = mysqli_fetch_assoc($result)) { echo "Username or password is incorrect"; } else { echo "You are logging in"; } //header("Location: index.php"); ?>
  14. warrens0017

    PHP Error - NOTICE: Undefined index

    Thank you very much. I read over the code like ten times and didn't notice that.
  15. warrens0017

    PHP Error - NOTICE: Undefined index

    Hi everyone. So I am have an issue to were I am trying to send information to my database and I get this error: NOTICE: Undefined index This is the code I am using: index.php <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Test Page</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <form action="signup.php" methos="POST"> <input type="text" name="first" placeholder="First Name"><br> <input type="text" name="last" placeholder="Last Name"><br> <input type="text" name="uid" placeholder="Username"><br> <input type="password" name="pwd" placeholder="Password"><br> <button type="submit">SIGN UP</button> </form> </body> </html> signup.php <?php include 'dbh.php'; $first = $_POST['first']; $last = $_POST['last']; $uid = $_POST['uid']; $pwd = $_POST['pwd']; $sql = "INSERT INTO username (first, last, uid, pwd) VALUES ('$first', '$last', '$uid', '$pwd')"; $result = mysqli_query($conn, $sql); ?> dbh.php <?php $conn = mysqli_connect("localhost", "root", "", "logintest"); if (!$conn) { die("Connection failed: ".mysqli_connect_error()); } ?> So this is the code I am using. I know it is connecting to the database because the PRIMARY KEY is entering without an issue but the information is now being filled in. I.E. First name, Last name, User, and Password. If anyone can help me that would be great.
×