Jump to content

pudge1

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pudge1's Achievements

Member

Member (2/5)

0

Reputation

  1. pudge1

    Search System

    I just got tired of it and completely restarted it and now it works. Thanks to all who helped!
  2. <form id="form" action="add_note.php" method="post" enctype="multipart/form-data"> <b>Note Title:</b> <input type="text" name="title" /><br /> <b>Note Keywords:</b> <input type="text" name="keywords" /><br /> <b>Grade Level:</b> <select name="grade_level"><option value="kt5">K-5</option><option value="6">6th Grade</option><option value="7">7th Grade</option><option value="8">8th Grade</option><option value="9">9th Grade</option><option value="10">10th Grade</option><option value="11">11th Grade</option><option value="12">12th Grade</option><option value="College">College</option></select><br /> <b>Subject:</b> <select name="subject"><option>Biography</option><option>Biology</option><option>Chemistry</option><option>Computer Science</option><option>Drama</option><option>Economics</option><option>Film</option><option>Health</option><option>History</option><option>Math</option><option>Philosophy</option><option>Physics</option>Poetry</option><option>Psychology</option>Shakespseare</option><option>Stories</option>Science</option><option>Sociology</option><option>U.S. Government and Politics</option></select><br /><br /> <b>Note File:</b> <input type="file" name="file" id="file" /><br /><small style="color:gray;">(Supported: .txt, .rtf, .doc, .docx)</small><br /><br /> <input type="hidden" name="submitted" value="TRUE" /> <input type="submit" id="submit" value="Add Note!" /> </form> <?php if($_POST['submitted'] == 'TRUE') { } else { include_once('right.php'); exit; } if($account_level == '_GUEST_' || !$account_level || $account_level == '') { echo "<meta http-equiv='refresh' content='0;URL=no_perms.php' />"; exit; } else { } $file_type = $_FILE['file']['tmp_name']; $file_type = explode('.',$file_type); $count = count($file_type); $count = $count-1; $file_type = $file_type[$count]; $file_type = '.' . $file_type; if($file_type != '.doc' || $file_type != '.DOC' || $file_type != '.txt' || $file_type != '.TXT' || $file_type != '.rtf' || $file_type != '.RTF' || $file_type != '.docx' || $file_type != '.DOCX') { echo "<script>alert('Your file type is not supported');</script>"; echo "<meta http-equiv='refresh' content='0;url=index.php' />"; exit; } else { } $rand = rand(10,900); move_uploaded_file($_FILES["file"]["tmp_name"],'tmp/' . $rand . $file_type); $note_contents = file_get_contents('tmp/' . $rand . $file_type); ... I am just trying to do a simple upload script to upload a text file and then get the contents of it. This should be really easy but for some reason $note_contents comes back blank and I just can't figure it out at all. Its really confusing and kind of frustrating. I have no idea why this isn't working at all... The file is not being uploaded and /tmp exists
  3. pudge1

    Search System

    Yes that is correct
  4. pudge1

    Search System

    Fixed that problem. Echoed it (just like the sql query would appear) and copied and pasted into PHPMyAdmin and it worked fine.
  5. pudge1

    Search System

    Thanks I can't believe I didn't notice that. However for some reason I still get the same error.
  6. pudge1

    Search System

    Oops copied the wrong problem sorry. function Search($keyword,$subject,$grade,$search_by) { $user = SQL_User(); $pass = SQL_Pass(); $dbname = SQL_DB(); $connection = mysql_connect('localhost',$user,$pass); mysql_select_db($dbname , $connection); $search_term = mysql_real_escape_string($search_term); $sql = "SELECT * FROM Notes WHERE Keywords LIKE '%$search_term%'"; if($subject == 'NO') { } else { $sql .= " AND Subject='$subject'"; } if($grade == 'NO') { } else { $sql .= " AND Grade='$grade'"; } if($sort_by == 'NO') { } elseif($sort_by == 'RATING') { $sql .= " ORDER BY Rating DESC"; } elseif($sort_by == 'VIEWS') { $sql .= " ORDER BY Views DESC"; } else { } $query = mysql_query($sql , $connection); while($arr = mysql_fetch_array($query)) { $title = file_get_contents('notes/' . $arr['Note_ID'] . '.note'); $title = explode('||TITL_E=',$title); $title = $title[1]; $title2 = explode('=||',$title); $user = SQL_User(); $pass = SQL_Pass(); $dbname = SQL_DB(); $search_term = mysql_real_escape_string($search_term); $connection = mysql_connect('localhost',$user,$pass); mysql_select_db($dbname, $connection); $sql = "SELECT * FROM Notes WHERE Note_ID='$note_id'"; $query = mysql_query($sql , $connection); $query = mysql_fetch_array($query); $title = $query["Title"]; $contents = $title2[1]; $contents2 = wordwrap($contents, 80, ",", true); $contents2 = explode(',',$contents2); $contents2 = $contents2[0]; if($contents2 == $contents) { } else { $contents = $contents . '...'; } $results .= "<a id='search_title' href='view_note.php?id=" . $arr['Note_ID'] . "'>" . $title . "</a><br />"; $results .= "<span id='search_contents'>" . $contents . "</span><br />"; $results .= "<span id='search_author'>" . $arr['Author'] . "</span><br /><br /><br />|*|?|>|"; } return $results; } For some reason I get these errors Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/***/functions.php on line 713 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/***/functions.php on line 713 I've looked over this many times. I even took the SQL Statement ($sql) and put it through the SQL Command on PHPMyAdmin and replaced the variable with what I am using as a keyword and it works just fine. But I can't figure out quite what is wrong. Line 713 Begins with While($arr...
  7. $user = SQL_User(); $pass = SQL_Pass(); $dbname = SQL_DB(); $search_term = mysql_real_escape_string($search_term); $connection = mysql_connect('localhost',$user,$pass); mysql_select_db($dbname, $connection); $sql = "SELECT * FROM Notes WHERE Keywords LIKE '%$search_term%'"; if($subject == 'NO') { } else { $sql .= " AND Subject='$subject'"; } if($grade == 'NO') { } else { $sql .= " AND Grade='$grade'"; } if($sort_by == 'NO') { } elseif($sort_by == 'RATING') { $sql .= " ORDER BY Rating DESC"; } elseif($sort_by == 'VIEWS') { $sql .== " ORDER BY Views DESC"; } else { } $query = mysql_query($sql, $connection); $query = mysql_fetch_array($query); Will query output a multi-dimensional array? If not how does it separate each result?
  8. function Vote($note_id,$rating,$username) { $note_id = mysql_real_escape_string($note_id); $rating = mysql_real_escape_string($rating); $username = mysql_real_escape_string($username); $user_votes = file_get_contents('user/' . $username . '_votes.dat'); $user_votes = explode(',',$user_votes); foreach($user_votes as $user_vote) { if($note_id == $user_vote) { return "False_1"; } else { } } $user = '***'; $pass = '***'; $dbname = '***'; $connection = mysql_connect('localhost',$user,$pass); mysql_select_db($dbname, $connection); $sql = "SELECT Votes FROM Notes WHERE Note_ID='$note_id'"; $query = mysql_query($sql , $connection); $query2 = mysql_fetch_array($query); $query = $query2["Votes"]; $query++; $sql = "UPDATE Notes SET Votes='$query' WHERE Note_ID='$note_id'"; $query = mysql_query($sql , $connection); $sql = "SELECT * FROM Notes WHERE Note_ID='$note_id'"; $query = mysql_query($sql , $connection); $query2 = mysql_fetch_array($query); $query = $query2["Total Rating"]; $query = $query+$rating; $sql = "UPDATE Notes SET Total Rating='$query' WHERE Note_ID='$note_id'"; $query = mysql_query($sql , $connection); $file = fopen('user/' . $username . '_votes.dat','a'); fwrite($file,$note_id . ','); fclose($file); } With the username I am using (user/pudge_votes.dat) the file is completely empty but for some reason it keeps returning False_1. I have no idea why it is doing this. Here is the page that the function is being used on. Also the database isn't updating like it should. It should get Votes from the table Notes where Note_ID=$note_id and increase its value by one and then update the vote count. Then it should get Total Rating from Notes where Note_ID=$note_id and add $rating to that value and then update the new value but neither of those are working either. $vote = Vote($_POST['id'],$_POST['rating'],Get_Username()); if($vote == 'False_1') { echo '<script>alert("You have already voted on this note. You may only vote once.' . $vote . '");</script>'; echo '<meta http-equiv="refresh" content="0;URL=view_note.php?id=' . $_POST['id'] . '" />'; exit; } else { echo '<script>alert("You have successfully voted on this note! Thank you for your contribution!");</script>'; echo '<meta http-equiv="refresh" content="0;URL=view_note.php?id=' . $_POST['id'] . '" />'; exit; }
  9. Yeah I even compared the md5s of the data that was being put into LogIn() and they matched up exactly in the database.
  10. Password shows up what it should but $a_password is empty. Sorry I forgot to mention that.
  11. For some reason my LogIn script doesn't work. It connects to the database and everything alright but it doesn't work at all. I've checked the database multiple time and the information I am inputting IS in there. function Login($username,$password) { $user = '***'; $pass = '***'; $dbname = '***'; $connection = mysql_connect('localhost',$user,$pass); mysql_select_db($dbname, $connection); $sql = "SELECT Password FROM Users WHERE Username='$username'"; $query = mysql_query($sql , $connection); $arr = mysql_fetch_array($query); $a_password = $arr["Password"]; if($password == $a_password) { setcookie('LOGGED_IN','True_',time()+172800); setcookie('USERNAME',$username,time()+172800); } else { } } That is the function here it is in use: $username = mysql_real_escape_string( $_POST['username'] ); $password = mysql_real_escape_string( $_POST['password'] ); $username = strtolower($username); $password = strtolower($password); $username = md5($username); $password = md5($password); Login($username,$password);
  12. So I am creating a sign up script and part of the script has a function that checks if a username exists but everytime I try it, it shows that the username is already in use when it isn't... the database is empty. function Check_Username($username) { $user = 'nintendo_note'; $pass = 'zeno118'; $dbname = 'nintendo_note'; $connection = mysql_connect('localhost',$user,$pass); mysql_select_db($dbname, $connection); $query="select Username from Users"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { if($username == $row['Username']) { return False; } else { } } } and the actual use: if(!Check_Username(md5($_POST['username']))) { echo "Sorry username is already taken. Please choose another."; include_once('right.php'); exit; } I tried changing a lot of things and moving things around but nothing seems to work. I have also gone over the code many times. The e-mail section is coded the exact same way but for some reason it always thinks the e-mail is never taken.
  13. Thank you so much exactly what I wanted.
×
×
  • 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.