Jump to content

membot

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Everything posted by membot

  1. I haven't used PHP in a while. I'm getting "unexpected T_ENCAPSED_AND_WHITESPACE" on the second line of this: if(isset($_GET['name'], $_GET['organization'], $_GET['email'], $_GET['message'])){ mail('memzenator@gmail.com', 'maybearobot: '.$_GET['organization'], "Name: $_GET['name'] /n/n Return Email: $_GET['email'] /n/n $_GET['message']"); }
  2. Oh. Yeah I was checking it at school, so they probably have an older version. Because it works for me at home too. Silly me!
  3. I made what I thought was a pretty simple CSS page, and was testing it as I coded in Google Chrome. Then I tested it in Firefox and box-shadow and transition weren't working. I don't know what could be causing this, since Firefox should support box-shadow, and -moz-transition is in the code. Here is a link, and you can view the source from there: http://students.4j.lane.edu/~mmatters32/ I haven't tested it in any other browsers, so if you have Safari or Opera you can tell me if you see shadows and transitions when you hover on the boxes. Thanks!
  4. I have a MySQL table for some photos (including columns like file path, caption, date, etc.), and I'm eventually making a PHP form I can use to upload photos and set the captions and whatever. However, initially, I want to add around 100 photos, and I'm thinking it would be easier to upload them all by FTP and have some kind of script (which I would only use this once) that would add all the photos in that folder to the MySQL table. Only the file path column would need to be filled out with this. I'm thinking this might not necessarily be a MySQL command or a PHP script, but I don't know anything about any other programming languages. Any help is appreciated.
  5. Well the thing is, I'm making an admin for the site, so the user will see these numbers and be able to change them. The idea is that if for example they want to put in a new row between rows 2 and 3, they could type 2.5 for the row number. Then when they save it and refresh the page, the rows are ordered with integers again. I've seen this exact thing done on other sites. Maybe it's not very efficient, but it'll do for me.
  6. Sorry if this belongs in the MySQL section. I figured it might be more of a PHP thing. I have a database where rows each have a number, which is used to determine what order they appear in on my PHP page. But right now they aren't like 1, 2, 3, 4, etc. They are a little jumbled because of deleting some and changing some, so they're more like 1, 3, 7, etc. Is there a way to make them 1, 2, 3, 4 with PHP? Like, put them in order and number them accordingly? Thanks.
  7. Oh wow, nevermind. I had the form action set to the wrong page. I am like the queen of stupid mistakes. x3
  8. Well isn't that what I did? If the login is correct, it's supposed to set the session variable and redirect to the admin page. And then the admin just checks if the variable is set and if it's not, it redirects to the login page. But when I try it (on WAMP), even after I log in it redirects to the login page again. So my thought was that somehow the session variable wasn't carrying over to the second page. :/
  9. This should be really simple, but I just can't figure out why it isn't working. It's my first time using sessions, so I'm probably doing something silly. It's just a login to an admin page. It's for a photo gallery, that's why the database is called "photo". This is the login page: <?php session_start(); if(isset($_POST['user']) && isset($_POST['password'])){ $user = $_POST['user']; $password = sha1($_POST['password']); $photo = new mysqli('localhost', 'user', 'password', 'photo'); $login = $photo->query("select user, sha1(password) from settings where user = '$user' and sha1(password) = '$password'"); if($login->num_rows > 0){ $_SESSION['login'] = 1; ?> <META HTTP-EQUIV="Refresh" Content="0; URL=admin.php"> <?php } else { $badlogin = 1; } } ?> <html> <head> <style> body {margin-top: 50px;} td {text-align: right;} input {width: 200px;} </style> </head> <body><center> <?php if(isset($badlogin)){ ?> <span style="color: red;">Oops! Wrong login.</span><br><br> <?php } ?> <table> <form action="admin.php" method="post"> <tr><td>User:</td><td><input type="text" name="user" /></td></tr> <tr><td>Password:</td><td><input type="password" name="password" /></td></tr> <tr><td></td><td><input type="submit" value="Login" /></td></tr> </form> </table> </center></body> </html> And this is the admin page: <?php session_start(); if($_SESSION['login'] != 1){ ?> <META HTTP-EQUIV="Refresh" Content="0; URL=login.php"> <?php } else { ?> <html> <head> </head> <body> Admin stuff here. </body> </html> <?php } ?>
  10. Oh sorry, didn't see that other post about the <br /> or <br> thing. But still, I'd like to know the other stuff.
  11. I've never used html/head/body tags in pages, yet w3schools says it's "required". What does that mean exactly? It obviously still works without them. Also, what's the point of using <br /> instead of <br>? Or <img src="" /> and <img src="">? Is it really more "correct" to use the extra slashes? And why, exactly, if it all works the same?
  12. What is the difference between EXTR_PREFIX_SAME and EXTR_PREFIX_IF_EXISTS?
  13. @DavidAM: Thank you so much! I didn't know that exit would stop stuff after the script too.
  14. @PFMaBiSmAd: I totally agree, but there is literally one computer class at my school (still in high school) and you get to choose what you learn. So it's not like it's specifically a PHP class, so they don't have it set up for people trying to learn PHP. I've had SO many issues with stuff also because they don't let you change permissions on things! And I could work on stuff at home, but I'd have to keep taking my files back and forth with a flash drive or something. It's a really annoying situation, but it's all I've got until I go to college.
  15. Well sure, that would be nice, but I'm in a class and that's just the way it is.
  16. Ok well... here's my whole source for the page. I don't think the quotes are the problem, but I don't know..... <title>Mem's Guestbook</title> <style> body {background: #33DDDD;} #content {background: #FFFFFF; width: 500px; font: 10px verdana,sans-serif; color: #3399AA; padding: 10px;} h1 {font: normal small-caps normal 30px georgia,serif; color: #33DDDD; text-shadow: #3399AA 1px 1px 3px} #cell {font: 10px verdana,sans-serif; color: #3399AA;} #input {font: 10px verdana,sans-serif; color: #3399AA; width: 150px; border: #3399AA 1px solid;} #submit {font: 10px verdana,sans-serif; color: #3399AA; border: #3399AA 1px solid; background: #89EBEB;} </style> <center> <div id="content"> <h1>Mem's Guestbook</h1> <!-- SCRIPT TO SHOW POSTS --> <?php $file = fopen("posts.txt", 'rb'); flock($file, LOCK_SH); while(!feof($file)){ $entry = fgetcsv($file, 0, '|'); if(empty($entry)){exit;} $d = $entry[1]; $n = $entry[2]; $s = $entry[3]; $m = $entry[4]; echo ' <table style="border: #3399AA 1px solid;"><tr style="background: #3399AA; font: bold 10px verdana,sans-serif; color: #FFFFFF;"> <td width="170">'.$n.'</td> <td align="right" width="170">'.$d.'</td> </tr> '; if($s != 'none'){ echo ' <tr><td colspan="2" style="font: 10px verdana,sans-serif; color: #3399AA;"> <b>Site: </b><a href="'.$s.'">'.$s.'</a> <center><div style="width: 250; height: 1px; background: #3399AA; margin: 10px;"></div></center></td></tr> '; } echo ' <tr> <td colspan="2" style="font: 10px verdana,sans-serif; color: #3399AA;">'.$m.'</td> </tr></table><br> '; } flock($file, LOCK_UN); fclose($file); ?> <!-- END SCRIPT --> <br><br><div style="width: 400px; height: 1px; background: #3399AA;"></div><br> You can leave a message in the guestbook with the form below.<br> Feilds with a "*" are required.<br><br> <?php if($_GET['error'] == 1){ echo '<font color="red">You must fill in your name and your message.</font><br><br>'; } if($_GET['post'] == 1){ echo '<font color="green">Your message has been posted. Thank you!</font><br><br>'; } ?> <form action="post.php" method="post"> <table> <tr><td align="right" valign="middle" id="cell">*Name:</td><td><input id="input" type="text" name="name" maxlength="50"></td></tr> <tr><td align="right" valign="middle" id="cell">Site:</td><td><input id="input" type="text" name="site" maxlength="200"></td></tr> <tr><td align="right" valign="top" id="cell">*Message:</td><td><textarea id="input" name="msg" rows="5"></textarea></td></tr> <tr><td></td><td align="center"><input id="submit" type="submit" value="Post"></td></tr> </table> </form> </div> </center>
  17. I feel like my life would be a lot easier if I could see the PHP error messages, but my school server is set to not show them, and I can't change it. Grrr.
  18. @unistake Umm, I don't think that's going to work. Why'd you take the last row of the table out of the loop? Also, you made the last echo double quotes, which will mess it all up.
  19. @Pikachu2000 Yeah, it isn't there. The source stops after the script too.
  20. I have a page that shows entries in a guestbook I'm making, and below the entries there is supposed to be a form to write an entry. Except, none of the HTML after the script to show the entries shows up on the page. I have no clue what's wrong. Here is the script to show the entries. $n is name, $d is date, $s is site (optional), and $m is message. $file = fopen("posts.txt", 'rb'); flock($file, LOCK_SH); while(!feof($file)){ $entry = fgetcsv($file, 0, '|'); if(empty($entry)){exit;} $d = $entry[1]; $n = $entry[2]; $s = $entry[3]; $m = $entry[4]; echo ' <table style="border: #3399AA 1px solid;"><tr style="background: #3399AA; font: bold 10px verdana,sans-serif; color: #FFFFFF;"> <td width="170">'.$n.'</td> <td align="right" width="170">'.$d.'</td> </tr> '; if($s != 'none'){ echo ' <tr><td colspan="2" style="font: 10px verdana,sans-serif; color: #3399AA;"> <b>Site: </b><a href="'.$s.'">'.$s.'</a> <center><div style="width: 250; height: 1px; background: #3399AA; margin: 10px;"></div></center></td></tr> '; } echo ' <tr> <td colspan="2" style="font: 10px verdana,sans-serif; color: #3399AA;">'.$m.'</td> </tr></table><br> '; } flock($file, LOCK_UN); fclose($file); The file it is reading looks like this: |11:51 am, 3rd Nov 2010|Memoria|none|Hello. |11:51 am, 3rd Nov 2010|Memoria|http://sitehere|Hello again. |11:51 am, 3rd Nov 2010|Memoria|none|How are you doing? Thanks!
  21. str_replace() will work great for me, 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.