Jump to content

WilliamNova

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by WilliamNova

  1. Can't believe I didn't notice that. Removing the comma did the trick. Thanks.
  2. I'm trying to complete a page where, when you click a button, it'll change a column from 0 to 1. I copied the code form another page of mine that's similar. I just changed the variables to match what I'm trying to change, so I'm not sure why it's not updating. delete_schedule.php <?php include ('./include/header.php'); $schedule_id = $_GET['schedule_id']; include ('./include/functions/deleteScheduleFunction.php'); ?> <div id="indexContainer"> <?php include ('./include/navigation.php'); ?> <div class='header'> Are You Sure? </div> <div class='indexBox'> Please confirm that you wish to delete this schedule. If you only need to edit the schedule you do not need to delete it, <a href=''>you can edit it here</a>.<br /> <br /> <form action='' method='POST'> <input type='hidden' name='deleted' value='1' /> <input type='submit' name='update' value='I am sure - Delete this schedule' /> </form> </div> <?php include ('./include/footer.php'); ?> </div> deleteScheduleFunction.php <?php if (isset($_POST['deleted'])) { $deleted = mysql_real_escape_string($_POST['deleted']); // Update mysql_query("UPDATE schedules SET deleted='1', WHERE schedule_id='$schedule_id'"); header("Location: home.php"); } ?>
  3. Okay, I figured it out. I changed the radio input fields to select/option fields and now it works perfect.
  4. Also, I have used error_reporting(E_ALL|E_STRICT); And nothing...
  5. Wasn't sure how to word the subject. Anyways, I have a form that is supposed to update multiple fields at once. Howevever, it's only updating the first one and that's gender. It will not update Location, or About or anything else. Here's the function that's in an include file. <?php if (isset($_POST['gender'])) if (isset($_POST['location'])) if (isset($_POST['about'])) if (isset($_POST['twitter'])) if (isset($_POST['facebook'])) { $gender = mysql_real_escape_string($_POST['gender']); $location = mysql_real_escape_string($_POST['location']); $about = mysql_real_escape_string($_POST['about']); $twitter = mysql_real_escape_string($_POST['twitter']); $facebook = mysql_real_escape_string($_POST['facebook']); // Update mysql_query("UPDATE users SET gender='$gender', location='$location', about='$about', twitter='$twitter', facebook='$facebook' WHERE user_id='$user_id'"); } ?> Here's the form <form action='home.php' method='POST'> <b>Gender:</b> <?php echo "$gender"; ?><br /> <input type='radio' name='gender' value='Male' />Male <input type='radio' name='gender' value='Female' />Female<br /> <br /> <b>Location:</b><br /> <textarea name='location' value='location' class='ta3'><?php echo "$location"; ?></textarea><br /> <br /> <b>About:</b> (150 chars or less)<br /> <textarea name='about' value='about'><?php echo '$about'; ?></textarea><br /> <br /> <b>My Twitter:</b><br /> @<textarea name='twitter' value='twitter' class='ta4'><?php echo "$twitter"; ?></textarea><br /> <br /> <b>My Facebook:</b><br /> facebook.com/<textarea name='facebook' value='facebook' class='ta4'><?php echo "$facebook"; ?></textarea><br /> <input type='submit' name='submit' value='Update' /> </form>
  6. Okay, I'm an idiot. I opened Chrome and it worked perfect. Then I realized I have an ad filter on Firefox and since I used the word 'ad' on the div, it blocked the image.
  7. I have no idea what I could be doing wrong. It's incredibly frustrating considering I've never had this problem. And more so, since I'm designing another website that has the SAME EXACT CSS for these divs. Anyways, the image will not show up. I have made sure the path is correctly spelled and that images folder exists. I have made sure the class names in both home.php and main.css are spelled correctly and match. home.php <div id="container"> <div class="adContainer"> <div class="ad"> <img src="./images/ad.png" width="600" height="100" /> </div> </div> </div> main.css #container { width: 1000px; background-color: #FFF; } .adContainer { margin-bottom: 10px; } .ad { border-top: 0px; margin-bottom: 10px; padding: 10px; height: 100px; width: 800px; }
  8. There's no PHP errors given. It's simply not inserting into the table. Which is why I believe I messed up somewhere, either accidentally added a character into something or removed one while I was editing the code.
  9. And for what it matters I have tried using die(mysql_error()); which gives me nothing and I always receive "Registered Successfully!"
  10. So I have a registration form for 'users' and another registration form for 'artists' and only one works, being the 'users' one. However, all I did for 'artists' was copy the same code from 'users' and then change what needed to be changed so it would insert into the 'artists' table and not the 'users' table. I just can't find where I messed up while doing this. $error = ""; if (@$_POST['register']) { $artistname = strip_tags($_POST['artistname']); $location = strip_tags($_POST['location']); $genre = strip_tags($_POST['genre']); $email = strip_tags($_POST['email']); $password = strip_tags($_POST['password']); $password2 = strip_tags($_POST['password2']); if ($artistname == "") { $error = "Artist Name cannot be left empty."; } else if ($location == "") { $error = "Location cannot be left empty."; } else if ($genre == "") { $error = "Genre cannot be left empty."; } else if ($email == "") { $error = "Email cannot be left empty."; } else if ($password == "") { $error = "Password cannot be left empty."; } else if ($password2 == "") { $error = "Repeat Password cannot be left empty."; } $check_email = mysql_query("SELECT email FROM artists WHERE email='$email'"); $numrows_email = mysql_num_rows($check_email); if ($numrows_email != 0) { $error = 'That email has already been registered.'; } else { //Register the user $register = mysql_query("INSERT INTO artists VALUES('','$artistname,'$location','$genre','$email','$password','','','no')"); die('<p style="padding: 10px;" /><b>Registered successfully!</b><br /><br /> <a href="artistlogin.php">Login now ></a></p>'); } } ?> <form action='artistsignup.php' method='POST' style='padding:10px;'> Artist Name:<br /> <input type='text' name='artistname' value='' onclick='value=""'/><p /> Location:<br /> <input type='text' name='location' value='' onclick='value=""'/><p /> Genre:<br /> <input type='text' name='genre' value='' onclick='value=""'/><p /> Email:<br /> <input type='text' name='email' value='' onclick='value=""'/><p /> Password:<br /> <input type='password' name='password' value='' onclick='value=""'/><p /> Repeat Password:<br /> <input type='password' name='password2' value='' onclick='value=""'/><p /> <input type='submit' name='register' value='Register' /> <?php echo $error; ?> </form>
  11. I know undefined variables are simple to fix, but I can't seem to get this fixed at all. <?php include ("./inc/headerinc.php"); mysql_connect("localhost","root",""); mysql_select_db("mid"); $email = $_GET['email']; $check_email = mysql_query("SELECT * FROM users WHERE email='$email'"); $count = mysql_num_rows($check_email); if ($count == 1) { while ($row = mysql_fetch_assoc($check_email)) { $id = $row['id']; $firstname = $row['firstname']; $lastname = $row['lastname']; $email = $row['email']; $password = $row['password']; echo "<h2>$firstname's Profile</h2><br /> Name: $firstname $lastname<br /> Email: $email "; } } ?> In line 7 'email' is undefined. When I try using isset($_GET ['email']) the error goes away, but none of the information that's suppose to echo is displayed.
  12. $data = mysql_query("SELECT * FROM news") or die(mysql_error()); $info = mysql_fetch_array( $data ); while($info = mysql_fetch_array( $data )) This is what I have thus far. Which all works just fine and when I use print it displays the correct fields, so I know the database is connected and is relaying information fine. I guess I'm not sure where I put this hand dandy code. <div id="news"> <div class="newsBody"> <div class="newsHeader"> <div class="newsDate"> Posted: <?php echo"$date"; ?> </div> <div class="newsAuthor"> Posted By: <?php echo"$author"; ?> </div><br /> <?php echo"$subject"; ?> </div> <div class="newsSynop"> <?php echo"$body"; ?> </div> </div> </div> I want to have those variables echo the database values. So I can't figure out how to get the info for author in Posted By: <?php echo"$author"; ?> and same with date, subject, body.
  13. So, I'm trying to display information from a table into my database on one of my pages. However, everything I've tried isn't working. Obviously, it's me. I know I'm doing something wrong, just not sure what. I deleted the PHP code related to querying and getting the information, again it was obviously done wrong anyways. So I have a table named 'news' and I have some columns, named 'author', 'date', 'subject', 'body'. I have some areas where I want those values displayed on my website in $author $date $subject $body Seems like whenever I alter the code I always have a new problem. I'm still learning PHP, so please don't just give me the code, I want to LEARN it, so if anything if you could break it down, that would be great and I hope it's not asking for a lot.
  14. I'm using md5 only because I'm new to this. I simply googled "how to encrypt passwords" and found a website tutorial pertaining to that. I know md5 isn't very secure, it was only for learning and I do plan on getting something better. But for now it will do since my website isn't even online and there's one user (me). The login logic makes sense since I scripted the encryption after both scripts were made and only modified the signin script. But I'll definitely look into crypt() and password_compat
  15. Still having some issues on my scripts. This time when I register a new user, which works fine, then I attempt to login into that user on the webpage, it doesn't go through, but if I go into my database and copy the column with the password that's been encrypted and paste it into the password field on the webpage, it works. I do have my script using md5 to encrypt the passwords the user sends to the database. I'm also salting for further security. <?php error_reporting(E_ALL); $error = ""; if ($_POST['register']) { $date = date("Y,-m-d"); $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $username = strip_tags($_POST['username']); $email = strip_tags($_POST['email']); $password1 = strip_tags($_POST['password']); $password2 = strip_tags($_POST['passwordrepeat']); $day = strip_tags($_POST['day']); $month = strip_tags($_POST['month']); $year = strip_tags($_POST['year']); $dob = "$day/$month/$year"; if ($firstname == "") { $error = "First Name cannot be left blank."; } else if ($lastname == "") { $error = "Last Name cannot be left blank."; } else if ($username == "") { $error = "Username cannot be left blank."; } else if ($email == "") { $error = "Email cannot be left blank."; } else if ($password1 == "") { $error = "Password cannot be left blank."; } else if ($password2 == "") { $error = "Repeat Password cannot be left blank."; } else if ($day == "") { $error = "The day of your birthday cannot be left blank."; } else if ($month == "") { $error = "the month of your birthday cannot be left blank."; } else if ($year == "") { $error = "The year of your birthday cannot be left blank."; } // Check for username existence. $check_username = mysql_query("SELECT username FROM users WHERE username='$username'"); $numrows_username = mysql_num_rows($check_username); if ($numrows_username != 0) { $error = 'That Username is already taken.'; } else { $check_email = mysql_query("SELECT email FROM users WHERE email='$email'"); $numrows_email = mysql_num_rows($check_email); if ($numrows_email != 0) { $error = 'That Email is already registered.'; } else { $salt1 = "great"; $salt1 = md5($salt1); $salt2 = "white"; $salt2 = md5($salt2); $salt3 = "void"; $salt3 = md5($salt3); $password1 = $salt1.$password1.$salt3; $password1 = md5($password1.$salt2); $password2 = $salt1.$password2.$salt3; $password2 = md5($password2.$salt2); if ($password1 != $password2) { $error = 'The Passwords do not match.'; } else { // Register the user $register = mysql_query("INSERT INTO users VALUES('','$firstname','$lastname','$username','$email','$password1','$dob','$date','no','')"); if(!$register){ die(mysql_error());} die("<h2>Success!</h2>"); } } } } ?>
  16. You're really like the most helpful guy in this entire community. The mysql error was "Column count doesn't match value count at row 1" At first I thought it was because I left "id" blank, which didn't make sense to me as its set to AI. But then I counted my columns in phpmyadmin (11). But my script was only inserting 10. Once I added the missing column it worked.
  17. The thing is, I haven't changed the code AND it worked fine before. phpmyadmin update itself at some point, I never really thought that it would have any effect, so never bothered to make sure information was still submitting. But once I made my video upload page and tried uploading a video, it never appeared in the database BUT I still got my "Success" page. I thought it was my code, redid it, but still nothing. Then I tried my photo upload page which hadn't been touched since I completed it and tested it. It didn't work. BUT still got the "Success" page. Likewise for my registration. However, my login page works, I can login. All those codes haven't been altered in any way since I completed and tested them. That's why I believe it's not the code. Anyways, here's my video upload page code, at the least the PHP side of it. <?php include ('./includes/header.php'); if (isset($_FILES['video'])) { $title = $_POST['video_title']; $desc = $_POST['video_description']; $keywords = $_POST['video_keywords']; $privacy = $_POST['privacy']; if (!empty($title) || ($desc) || ($keywords) || ($privacy)) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $video_id = substr(str_shuffle($chars), 0, 15); $video_id = md5($video_id); } else { die('empty fields'); } if (($_FILES['video']['type']=='video/mp4')) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $random_directory = substr(str_shuffle($chars), 0, 15); if (file_exists('data/users/videos/' . $random_directory . ''.$_FILES['video']['name'])) { echo 'video exists'; } else { move_uploaded_file($_FILES['video']['tmp_name'],'data/users/videos/' . $random_directory . ''.$_FILES['video']['name']); $img_name = $_FILES['video']['name']; $filename = "data/users/videos/".$random_directory.$_FILES['video']['name']; $md5_file = md5_file($filename); $check_md5 = mysql_query("SELECT file_md5 FROM videos WHERE file_md5='$md5_file'"); if (mysql_num_rows($check_md5) != 0) { unlink($filename); die("This is a duplicate upload"); }else { $date = date("F j, Y"); $insert = mysql_query("INSERT INTO videos VALUES ('','$title','$desc','$keywords','$user','$privacy','$date','0','$video_id','')"); mysql_query("UPDATE videos SET file_md5='$md5_file' WHERE video_id='$video_id'"); die("<h2>Success!</h2><br /> Please allow up to 15 minutes for your video to be visible to all users.<br /><br /> <a href='upload.php'>Upload another</a><br /> <a href='members.php'>Go home</a>"); } } } } ?>
  18. Here's a pic. It's at the very top of every table in my database. Sorry if I'm not explaining this well. I'm new to databases. Also, I went through my permissions for phpmyadmin users. I had all permissions checked for the user I'm using and just to be sure I granted all permissions to all users and still nothing.
  19. I put in some error reporting code and it returned nothing. But then I noticed in my database in the tables there's this snippet of code SELECT * FROM `subscriptions` LIMIT 0 , 30 So, like you said, it's only allowing SELECT (or so I assume) How can I change this to allow more than SELECT?
  20. I'm really not sure what's going on with my database. But it was working 100% fine a week ago. But some of it does work, such as, I can login to my website BUT I cannot register new accounts. I can't subscribe to other users and I can no longer upload photos, videos, etc. I guess, in other words, I can only login. But I haven't altered the code on most of these pages, just the video and image upload pages, so if it were code the registration page should work fine and the subscribe. So I'm curious, is there any reason why the database would only partially work? If it helps, phpMyAdmin did update on its own recently, around the same time some stuff stopped working. I'm also using XAMPP and only running Apache and MYSQL.
  21. I found the error and I should have looked more closely at my form, which I didn't even think was the problem. <form action='upload_image.php' method='POST' encytype='multipart/form-data'> Spelled enctype wrong.
  22. So I'm making an upload file for my website for users to upload images. However, it's not working and I have no clue why. This is the entire php script for this page becuase I'm not sure what could be causing it. <?php include ( './includes/header.php' ); if (isset($_FILES['channel_pic'])) { if (($_FILES['channel_pic']['type']=='image/jpeg') || ($_FILES['channel_pic']['type']=='image/png') || $_FILES['channel_pic']['type']=='image/gif') { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $random_directory = substr(str_shuffle($chars), 0, 15); if (file_exists('data/channels/images/icons/' . $random_directory . ''.$_FILES['channel_pic']['name'])) { echo 'image exists'; } else { move_uploaded_file($_FILES['channel_pic']['tmp_name'],'data/channels/images/icons/' . $random_directory . ''.$_FILES['channel_pic']['name']); } } if (($_FILES['channel_pic']['type']=='image/jpeg') || ($_FILES['channel_pic']['type']=='image/png') || $_FILES['channel_pic']['type']=='image/gif') { } else { die('Invalid File'); } } ?> So, let's see. The die function won't work when I upload, say a .RAW format. And it should upload any jpeg's, png's, or gif's to a randomly created directory. Which it's not doing. The folders do exist --> data/channels/images/icons
  23. I've also just noticed even when I intentionally type the corrent username, but enter an incorrect password, it doesn't tell me, which it should. "The username or password is incorrect - Try again."
  24. headerinc is included on index.php, in fact it's line 1. Unless I typed it out wrong, which I don't think so. <?php include "inc/incfiles/headerinc.php";?>
×
×
  • 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.