Jump to content

MrXander

Members
  • Posts

    73
  • Joined

  • Last visited

Everything posted by MrXander

  1. Thanks for your reply. I have attempted to use this, but it just massively duplicates the comments that I am pulling (ten fold). Can you advise?
  2. Hi guys. I'm making a comment system for my website but I'm a bit stuck. I need to be able to alternate the style of every other comment with the stylesheet I have set, but how do I do this while fetching results from my database? I need to change the <li class="comment_even"> to <li class="comment_odd"> every other comment. <?php $sql2 = mysql_query("SELECT * FROM `comments` WHERE `relatingto`='".$_GET['id']."' AND `hidden`='No' AND `deletedbyadmin`='No'"); while($dat2 = mysql_fetch_array($sql)){ ?> <li class="comment_even"> <div class="author"><img class="avatar" src="images/avatar.gif" width="32" height="32" alt="" /><span class="name"><a href="#"><?php echo $dat2['poster']; ?></a></span> <span class="wrote">wrote:</span></div> <div class="submitdate"><a href="#"><?php echo $dat2['time']; ?></a></div> <p><?php echo $dat['comment']; ?></p> </li> <?php } ?>
  3. Hi Guys, This might be a really dim question, but I need assistance with the round() function. I am trying to show a rounded figure of, for example $3.50, but using round, it is dropping the last zero. The line of code being used is: $price1 = round($personal1 * $rate, 2); Is there anyway to avoid this and display the last zero? Thank you!
  4. All the validation has been done against the database. Basically, all I want is for a user to enter their information, press submit, then a new page loads saying "Please Wait" - then ~5 seconds later, text to show underneath showing "account created".
  5. Are you able to elaborate on that? I've checked out the link that you posted, but that would be with using a button, whereas I need this to display automatically and not in an alert box. Sorry if that sounds dumb :-)
  6. Hi. Is there anyway to delay output displayed on a page? I'm using this as part of registering for my new website. While the script checks that what the user has created, I want a small delay (of around 5 seconds or so) then the output, either being "TRUE" or "FALSE" to be sent back, WITHOUT redirecting to another page. Any suggestions?
  7. Sorry, I've figured it out: '.($e == 1 ? "" : "s").' Thanks anyway!
  8. Attempt this: <?php require("global_navigation.php"); $name = $_SESSION['username']; $newuser = $_POST['newuser']; if ($_SESSION['username']) { if (strlen($newuser)<=$usermax) { echo "Username must be at least $usermax characters long!"; } else { //display data $get = mysql_query("SELECT * FROM users WHERE username='$name'"); while ($row = mysql_fetch_assoc($get)) { // get data $points = $row['points']; } } if ($points >=50) { //protection $before = array('(', ')', '^', '<', '>', '`', '*', '<script>', '</script>', ';DROP TABLE users;', 'users', 'DROP', 'TABLE'); $after = array('', '', '', '', '', '', '', '', '', '', '', '', ''); $output = str_replace($before, $after, $newuser); //connect $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); //checking $query = mysql_query("SELECT * FROM users WHERE username='$output'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo "This username is currently being used!"; } else { //write mysql_query("UPDATE users SET username='$output' WHERE username='$name'") or die(mysql_error()); echo "<center><div class='box'><span style='color:green'>Thank you $name, you have successfully edited your username to: <b>$output</b> <a href='index.php'>Return home</a></span></div></center>"; $_SESSION['username']=$output; } } else { echo "Mo"; } } else { echo "You must be logged in to change your username."; } ?> Appears the first ELSE statement wasn't closed...
  9. Try this: <?php include("Newsletter Beta/include/database.php"); include("Newsletter Beta/include/mailer.php"); include("Newsletter Beta/include/form.php"); class Session { /* Class constructor */ function Session(){ $this->time = time(); $this->startSession(); } function startSession(){ global $database; //The database connection session_start(); //Tell PHP to start the session } function register($subemail, $subuser_code){ global $database, $form, $mailer; //The database, form and mailer object } /* Email error checking */ $field = "email"; //Use field name for email if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "* Email not entered"); } else{ /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); $subemail = stripslashes($subemail); } else if($database->emailTaken($subemail)){ $form->setError($field, "* Email already been subscribed"); } } /* Captcha error chcking */ $field = "captcha"; //Use field name for gender if (strcmp(md5($subuser_code),$_SESSION['ckey'])){ $form->setError($field, "* Captcha image is incorrect"); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the database */ else{ $activ_code = rand(1000000,9999999); if($database->addNewUser($subemail, $activ_code)){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subemail,$activ_code); } return 0; // New user added succesfully }else{ return 2; //Registration attempt failed } } }; $session = new Session; /* Initialize form object */ $form = new Form; ?> You need to double check you're closing all your functions.
  10. Hi Guys, I used to use a single line of code, where if more than one error occured, it would show for example: "2 errors found" Whereas if only one was found, would echo: "1 error found" I can't remember how on earth I did this so any assistance would be appreciated.
  11. Can anyone offer any advise with this??
  12. Hi Guys, Need a little guidance. I'm trying to get my script to communicate with cPanel (or WHM) to show certain statistics, for example, how much space/bandwidth has been used. I have been reading through the documentation found at: http://twiki.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ShowAccountInformation Using this, I have managed to get it displaying ALL account information, but it states you can basically pick out specific information, which I can't seem to get working. Can someone help with an example of displaying just disk space used please? Thank you!
  13. Well, the script is devloped with the variables not defined, so I will have to edit every page so that it will pick it up. Surely though there is a way round this, as they developed it like this?
  14. No, unfortunately. There may be one line the same on each page, for the navigation, setting $p = $_GET['p'], for example. The unfortunate thing is, there is forms and submit buttons, so I will also have to go through and define, for example, $submit = $_POST['submit']. Is there not something I can enable on my server to get around this?
  15. Hi Guys, Might be a simple question, but I just downloaded a PHP script that I want to modify slightly, only problem is, I have been through 5 pages (out of about 150) adding the lines, such as $p = $_GET['p'];, as it's not picking it up. Is there anyway round it? Thanks
  16. I know, I was just using that as an example... That's spot on, thank you!!
  17. That post wouldn't do it though. Take his example for years... it would show as 8.6 (or there abouts). What I want it to do is stop at the closest year, then count the left overs as days. So, if the timestamp was for 1st July 2000 and todays date is 21st July 2008, I need it to say 8 years and 20 days, instead of ~8.6 or 2848 days. See what I mean?
  18. Sorry, maybe I didn't express myself very clearly. For example, if the unix timestamp read 1st July 2000, I want it to show the following: 8 years, 22 days How would I go about that?
  19. Hi Guys, Trying to display, from a UNIX timestamp, how long it has been since that timestamp, but only showing years & days. Could someone help? Thanks!
  20. Hi Guys, Trying to make my life a little easier. I am looking for either a free or cheap PHP program to create quotes on, and if the order is a go ahead, transform the quote into an invoice when the job is created. To be honest, I don't have the time to be making one myself. Is there such thing out there?!
  21. Are you sure? That would really suck...
  22. Hi, Could someone point me in the way of a tutorial or code samples of how to make a list in php of one to fifty? By that, I don't mean a numerical list, I mean actually: One Two Three etc Any help would be appreciated. Thank you.
  23. Hi Guys, Is there any way to reverse words with PHP, depending on what a user submits? For example, if a user enters: "I want this text reversed" It would display as either: "reversed text this want I" or, even better: "desrever txet siht tnaw I" Any help would be appreciated! Thanks.
  24. Hi Guys, Need a little help. I need to generate a list, for example: aa ab ac ad through to az After that, I need to generate: ba bb bc bd through to bz So on and so forth. Is there anyway I can do this? Thanks in advance!!
  25. That's the easy bit, I know how I'm going to do that. The thing is, I need possibly a mail handler? Something that will not only create the email address, for example, joe.bloggs@mydomain.com, once the user signs up, but also be able to pick up email sent to joe.bloggs@mydomain.com, via the web access...
×
×
  • 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.