Jump to content

ryanmetzler3

Members
  • Posts

    77
  • Joined

  • Last visited

Everything posted by ryanmetzler3

  1. I have found that the error is always at the line where the first php tag occurs. Right now it is reading an error at line 12 which is the first php tag in the code. If I delete that section (because it does not contribute to the functionality of the code) , the errror reads line 19 which is the next php tag. If I delete that, the error jumps to the next php tag. It doesnt like the first php tag for some reason.
  2. Here is all the code. I put line 12 in red so you can see it easier. Thank you <html> <head> <link rel="stylesheet" type="text/css" href="/style.css" /> <link rel="stylesheet" type="text/css" href="/login_scripts/user_style.css" /> <title>Wet Dog Nose Polls</title> </head> <body> <div id="wrapper"> <div id="headerwrap"> <div id="header"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/header_source/index.php'; ?> <a href="/index.php"> <img src="/images/wetdognose.jpg"> </a> </div> </div> <div id="navigationwrap"> <div id="navigation"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/menu_source/index.php'; ?> </div> </div> <div id="loginwrap"> <div id="login"> <h2>Welcome back! Sign in here.</h2> <?php include $_SERVER['DOCUMENT_ROOT'] . '/login_scripts/sessionstart.php'; if (isset($_POST['loginbtn']) or ($username && $userid)) {} else{echo "";} if ($username && $userid) { echo "You are already logged in as <b>$username</b>"; echo "<br/>Not " . $username . "? <a href='/login_scripts/logout.php'>Logout</a>"; } else { $form = "<div id='forms'> <form action='/login_scripts/login.php' method='post'> <table class='forms'> <td><input type='text' name='user' placeholder='Username' class='input_style'/></td> </tr> <tr> <td><input type='password' name='password' placeholder='Password' class='input_style'/></td> </tr> <td><input type='submit' name='loginbtn' id='loginbtn' value='Login'/></td> </tr> <tr> <td><a href='/login_scripts/register.php'>Register</a> <a href='/login_scripts/forgotpass.php'>Forgot Password?</a></td> </tr> </table> </form> </div>"; } if ($_POST['loginbtn']) { $user = $_POST['user']; $password = $_POST['password']; if ($user) { if ($password) { include $_SERVER['DOCUMENT_ROOT'] . '/login_scripts/connect.php'; $password = md5(md5("R4E2M0".$password."R4E2M0")); $link = mysqli_connect("localhost","wetdogno_ryan","Relztem$3","wetdogno_login") or die ("Cannot connect"); $query = mysqli_query($link, "SELECT * FROM user WHERE username='$user'") or die (mysqli_error()); $numrows = mysqli_num_rows($query); if ($numrows ==1) { $row = mysqli_fetch_assoc($query); $dbid= $row['id']; $dbuser= $row['username']; $dbpass = $row['password']; $dbactive = $row['active']; if ($password == $dbpass) { if ($dbactive == 1) { $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; header('Location:/login_scripts/member.php'); } else { echo "<font color='red'>You must activate your account to login. $form</font>"; } } else { echo "<font color='red'>You did not enter the correct password. $form</font>"; } } else { echo "<font color='red'>The username you entered was not found. Be sure that you are entering your username and not email.$form</font>"; } } else { echo "<font color='red'>You must enter your password . $form</font>"; } } else { echo "<font color='red'><p>You must enter your username. Be sure you are entering your username and not your email. $form</font>"; } } else{ echo $form; } ?> </div> </div> <div id="rightcolumnwrap"> <div id="rightcolumn"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/ad.php'; ?> </div> </div> <div id="footerwrap"> <div id="footer"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/footerlinks.php'; ?> </div> </div> </div> </body> </html>
  3. I have a script where a user can register and then login to my site. It all works fine on WAMP. When I put it on a live server I am having issues. I am getting this error when you try to login. Warning: Cannot modify header information - headers already sent by (output started at /home/wetdogno/public_html/login_scripts/login.php:12) in /home/wetdogno/public_html/login_scripts/login.phpon line 75 I know sessions are not starting becuase normally when you register, it automatically logs you into the account you just created, but its not doing that. It creates the user, because their information gets injected into my DB. Their session just isn't starting. Also the header() function is not working. Here is the code that the error message describes. I really don't think its a white space issue like many of the blogs that I have read indicated. f ($password == $dbpass) { if ($dbactive == 1) { $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; header('Location:/login_scripts/member.php'); }
  4. Hello everyone, I just wrote a significiant amount of code using mysql commands. I am now finding out that mysqli is the better option. Will mysql commands not work in the future? Do you have to switch to mysqli to avoid any potential issues?
  5. I have a comment section. It is comprised of 3 major files. One file creates the form where you fill in your name and comment. Another file sends your comment to the DB. The third file displays the already existing comments on the page. You have the option to reply to the existing comments on the page. When you click the reply button I would like the comment text box to light up so the user knows its working but I have hit a brick wall. This is the comment form the user actually types into: <div id="comment-container" > <form id="comment_form" action="/comm_1/post_comment.php" method='post' onsubmit=" return validateForm()"> <table> <tr> <td id="error"></td> </tr> <tr> <td><textarea name="comment_body" id='comment_body' placeholder="Comment"></textarea></td> </tr> <?php if(!$username && !$userid): ?> <tr> <td><input type="text" name="name" class="input_style" placeholder="Name"/> <input type="submit" id="loginbtn" value="Or Login" onclick="window.location='/login_scripts/login.php'" /></td> </tr> <tr> <td><input type="email" name="email" class="input_style" placeholder="Email"/></td> </tr> <?php endif; ?> <?php if($username && $userid): ?> <input type="hidden" name="name" value="<?php echo htmlspecialchars($username) ?>"/> <input type="hidden" name="email" value="<?php echo htmlspecialchars($email) ?>"/> <?php endif; ?> <tr> <input type='hidden' name='parent_id' id='parent_id' value='0'/> <td><input type="submit" name="submitbtn" id="submitbtn" value="Add comment"/></td> </tr> </table> </form> This how the existing comments are displayed on the page: You can see on line 7 is the button to the reply to a comment. When this is clicked I need the "comment_body" from the above code to highlight. <?php function getComments($row) { echo "<li class='comment'>"; echo "<div class='aut'>".$row['author']."</div>"; echo "<div class='timestamp'>".$row['created_at']."</div>"; echo "<div class='comment-body'>".$row['comment']."</div>"; echo "<a href='#comment_form' name='replybtn' class='reply' id='".$row['id']."'>Reply</a></script>"; $q = "SELECT * FROM threaded_comments WHERE parent_id = ".$row['id'].""; $r = mysql_query($q); echo "</li>"; if(mysql_num_rows($r)>0) { echo "<ul>"; while($row = mysql_fetch_assoc($r)) { getComments($row); } echo "</ul>"; } } ?> I tried this with JS, but it does not work: $(function(){ $("a.reply").click(function() { var id = $(this).attr("id"); $("#parent_id").attr("value", id); $("#comment_body").focus(); }); });
  6. I have a poll on my website. The question and answers for the poll are stored in a database. When I want to change the poll I simply change the question and answer options in the database. Here is the problem. When you vote it registers a cookie and then knows to display the results rather than the question. Like so: setcookie("voted".$_POST['pollid'], 'yes', time()+86400*300); Unfortunately when I change the question the old cookies are still in place. So it is automatically showing the results to the new question even if you only already voted on the previous question. Is there a way to detect if you voted on the old poll, and clear your cookie if you voted on the old one?. Really lost on how to solve this. I was thinking something like this: if(some constraint to distinguish old cookies maybe a time-stamp?){ $_COOKIES = array(); }
  7. yea sorry about. I though I could simplify my question a lot better but could not figure out how to delete the old one.
  8. I have a poll on my website. If you vote, then it registers a cookie and displays the results. It will continue to show the results even if you refresh the page because of that cookie. My problem is if I change the question then I want it to start fresh. Unfortunately if the user has not cleared their cookies from the last time they voted, it automatically displays the results even if the question was updated. I tried something like this: $_COOKIE = array(); this does not work because then it always clears it every time anyone visits. I just need to somehow wipe everyone's clean once when I update the question??
  9. I downloaded a script for a poll/voting kinda thing for all my site visitors a while ago and then I tweaked it a bit. It is linked to a database. It grabs the question and possible answers from one database. It also stores user votes, ip addresses, and the date they voted in a database. I went to change the question and possible answers in my poll by simply changing the options in the Database. This worked fine, but I found a big problem! If you have already voted in the poll, then it displays the results to you every time you visit the site . I assumed this was based off your IP since it is recorded in the database. So logically I thought if you cleared all the IP's in the DB, then the new question would display for every user, but to my alarm it is based off cookies. This is problem because even though I changed the question and options, if people have not cleared their cookies from the last time then the poll still displays the results even though they have not voted on the new question yet. Is there someway to clear everyone cookies or make the poll start fresh for everyone without drastically changing the code and how the entire thing works?
  10. I have two comment sections. The data from the first is saved in threaded_comments (a table), the second comment section saves its data in threaded_comments2. I have attached a screen shot of the structure of the tables. The two tables have the same structure and sit in one DB. If you post an original comment, it gets a parent_id of 0. If you reply to a comment its parent_id matches the id of the comment it is in reply to (You can see this in the pic). If a user logs in, I would like to have a section where they can view their recent comments ONLY and see if anyone has replied to them. I ran a query to do this as follows: //connection include $_SERVER['DOCUMENT_ROOT'] . '/comm_1/config.php'; // gets original comments only, And only those posted by the user currently logged in. $sql = "SELECT *, 0 as section FROM threaded_comments WHERE parent_id = 0 AND author = '$username'" . "UNION SELECT *, 1 as section FROM threaded_comments2 WHERE parent_id = 0 AND author = '$username'"; $result = mysql_query($sql); while ($link = mysql_fetch_assoc($result)) { yourComments($link); } //this function gets all the information from the rows in the DB function yourComments($row) { echo "<li class='comment'>"; echo "<div class='aut'>".$row['author']."</div>"; echo "<div class='timestamp'>".$row['created_at']."</div>"; echo "<div class='comment-body'>".$row['comment']."</div>"; //this query checks if there is any replies to the comments fetched by the original query and displays them. $q = "SELECT *, 0 as section FROM threaded_comments WHERE parent_id = ".$row['id']." " . "UNION SELECT *, 1 as section FROM threaded_comments2 WHERE parent_id = ".$row['id'].""; $r = mysql_query($q); echo "</li>"; if(mysql_num_rows($r)>0) { echo "<ul>"; while($row = mysql_fetch_assoc($r)) { yourComments($row); } echo "</ul>"; } } The problem is a comment from the first table may have an id of "1" and therefore a reply to this comment would have a parent_id of "1". This same exact scenario is possible to happen in table 2. So for example the comment with the id of 1, displays. Then all the comments with a parent_id of "1" display as a reply to it (even though they could be coming from both table). I will attach a screen shot of this issue to help make it more clear. Any idea how to fix this?
  11. I have a DB with 4 tables in it.There is 4 different comment sections on my website, so each table has the same structure, but holds information unique to that comment section. Im trying to query all 4 tables and pull the comments by one specific user from all of them. But the row "comment" is in all 4 tables, it says it is ambiguous and wont work. Is there anyway around this? Or do I have to rename the columns in each table? <?php include $_SERVER['DOCUMENT_ROOT'] . '/comm_1/config.php'; $query= "SELECT comment FROM threaded_comments,threaded_comments2,threaded_comments3,threaded_comments4 WHERE author = '$username'" or die (mysql_error()); $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo $row['comment']; } ?>
  12. Do something like this: <input type="image" src="rainbow.gif" name="image" width="60" height="60"> It is technically not a button, but you can use the src attriubute for you image. Then use the onClick function to direct the user wherever you want.
  13. I have a comment section that I use 'ul' tags to show the replies to a previous comment with an indent. I attached a picture of this. Right now the 'ul' tag is indenting original comments and indenting replies even more. I want to slide all the original comments over so they sit flush to the left in the box, but keep an indent for the replies. I tried this all of these independently: ul{ padding: 0px; margin-left:0px; padding-left: 0px; } but that takes the indent off of everything. Here is the snippet of code that displays the comments if(mysql_num_rows($r)>0) { echo "<ul>"; while($row = mysql_fetch_assoc($r)) { getComments($row); } echo "</ul>"; } } any idea how to do this?
  14. I have a comment section on my website. It requires your name, email, and comment. You can opt to login and then you do not have to fill in your name and email. My form looks like this: <tr> <td><label for="name">Name:</label></td> <input type="submit" id="loginbtn" value="Or Login" onclick="window.location='/login_scripts/login.php'" /></td> </tr> <tr> <td><label for="name">Email:</label></td> <td><input type="email" name="email" id='email'/></td> </tr> Once you login, the name and email fields disappear and you can just comment. I grab your user name from the database and insert that as your comment name. Anyways, how can I redirect them back to the comment section after they have been logged in? assuming they arrived at the login page from this specific login button...
  15. Thanks, since I copied the first file to make the second I have some div's with the same name. I did not think that would matter since they are sitting inside folders with different names but I will change that and see how it works. I appreciate the suggestion!
  16. I have two folders, one is called "ajax_poll_1" and the other is "ajax_poll_2". They are basically a script for a quick poll. I wanted two polls on my site so I copied the first one and made some slight adaptations to it. They both work great. If I type in localhost/ajax_poll_1 or localhost/ajax_poll_2 they both work well. Its when I try to include them on the home page they go awry. I did this: <div id="contentwrap"> <div id="content"> <div class="poll1"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/ajax_poll_1/index.php'; ?> </div> <div class="poll2"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/ajax_poll_2/index.php'; ?> </div> </div> </div> If I only include one at a time it works great. If I include them both one overwrites the other. For example when I run this code ajax_poll_2 actually displays over the top of ajax_poll_1 in the poll1 div. Its driving me crazy. The only errors I have are undefined variables because they are not set until the user submits their vote. I just suppressed them because it works fine and I think it has nothing to do with this problem. Anyone know whats going on?
  17. I am confident that the files have been adapted correctly for the new database because when I open the file directly (localhost/ajax_poll_2) everything works great. Are you asking what index.php contains, like the absolute homepage? Or the index.php inside the ajax_poll_2 folder?
  18. I have a folder containing an ajax poll script. I have the folder saved as "ajax_poll_1". It takes the poll question, potential answers, and votes from a database called "poll1". I included this on my homepage like so: <div class="poll1"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/ajax_poll_1/index.php'; ?> </div> This displays the poll on the homepage and it works great. I copied the entire folder because I wanted 2 polls on my homepage. I renamed the copied folder "ajax_poll_2". I created a second database to contain the data for the second poll and made slight adaptations in the code since the folder was renamed and it was linked to a new DB. The new poll does work when you open the folder directly like so: localhost/ajax_poll_2. If I try to include the second poll on the homepage it does not show up correctly. It shows a grey box that the poll is supposed to sit in, but does not display the text. I know the poll works, and I am essentially including it the exact same way as the first poll so I can't figure out why its failing. <div class="poll2"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/ajax_poll_2/index.php'; ?> </div> Is there some dumb mistake I don't see?
  19. Thanks for the info. I tried this and adapted things like you said, but it is still messed up. I will attach a screen shot of what it looks like. Normally the poll sits inside the square box with the title "User Poll". But for some reason the box contains nothing and it just says loading... Then the poll displays below it outside of its div. If you have any quick ideas, I thank you for them ahead of time!
  20. I have written code to make a poll. You make a choice, then it takes your vote and displays the results. I have it all in a folder called ajax-poll. Like this: Main directory for website: index.php Folder ajax-poll: -main.php -poll.php -jquery.1.3.2.js -styes.css If I go to localhost and open the ajax-poll folder specifically it works great. I then did this on index.php to actually display it on the homepage. <head> <link href="../ajax-poll/styles.css" rel="stylesheet"> <script type="text/javascript" src="../ajax-poll/jquery-1.3.2.js"></script> </head> <body> <?php include "../ajax-poll/main.php"; include "../ajax-poll/poll.php"; </body> Basically I just tried to include all the files inside ajax-poll on the homepage. It works somewhat. The functionality of the poll still works, but the animation I have written into the script does not work. Also the css looks really messed up and it is not sitting inside its border like it should. It still works great if you just open the ajax-poll folder directly. Any idea why or how to fix this?
  21. yea actually I do not know what I was thinking. I will just place the style code from the poll folder into the mail css sheet for the site and see if it works. Thanks, I was just thinking really illogially
  22. Thanks for the response. I did this: <?php foreach (glob("ajax-poll/*.php") as $filename) { include $filename; } ?> Basically it loops through to get all the files inside the "ajax-poll" folder and includes them on the homepage of my website.
  23. I have written code that is a web poll/survey. It consists of 4 files: index.php poll.php jquery-1.3.2.js styles.css These are all saved in a folder called ajax-poll. I tried to include that entire folder on the index.php home page of my website but the css and animation does not work when I do this. If I open the ajax-poll folder independently on localhost then everything works great! It is just when I include the whole folder on another page it fails. The functionality of the poll still works, just the css and animation does not work. Any idea why?
  24. I have not, I really did not have the slightest clue how you could accomplish something like this. I am on Yahoo's API site right now but they don't give an explanation to what it really is. Can you tell me real quick just a basic summary of what it is and how it works? I'd be very appreciative
  25. There was a guy named Benjamin Graham who was a pioneer of investing in the market. He has a formula that is still widely used today to find undervalued stocks. I would like to create a site that you simply enter the ticker symbol of a stock and it calculates the "value" for you. You need expected 5 years growth, earnings per share, and aaa corporate bond yield. Yahoo finance has all these numbers readily available. Is it possible to write a program that would receive the ticker symbol then pull that data from yahoo and run it through the code? Or do I pretty much need my own DB of info on every stock out there?
×
×
  • 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.