Jump to content

pocobueno1388

Members
  • Posts

    3,369
  • Joined

  • Last visited

    Never

Everything posted by pocobueno1388

  1. Okay, I figured out how to get the errors to display out of the class. I did it like this: I added the error variable like this: <?php class user { var $userID; var $username; var $money; var $rank; var $account_type; var $email; var $password; var $error; //<------added ?> Then I assigned the errors to the variable from inside the class (obviously) like this: $this->error[] = "Error"; Then could access them like this: $user = new user($sid); $user->setEmail("email_goes_here"); print_r($user->error); NOW the problem is that I want the $error variable to be set to the $error variable that already exists from outside the class. So how I would I go about doing that? I figured it will be something like this: class user { var $error = global $error; That didn't work though...it threw a syntax error.
  2. I am trying to set an array full of errors from inside my class, but I would like to be able to use that array outside of my class so I can echo it out. Here is the code to the function inside the class. <?php function setEmail($email){ $emailChk = mysql_query("SELECT email FROM users WHERE email='$email'"); //Make sure it's valid if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) || $email == ""){ return $error[] = "Email is not valid"; return $error[] = "2nd error"; //Make sure the email isn't already in use } else if (mysql_num_rows($emailChk) > 0){ return $error[] = "This email is already in use by another account."; } else { //everything is good, change the email. } } ?> Here is how I am using the class. <?php $user = new user; $user->setEmail("email_goes_here"); print_r($error); ?> How could I get the $error array able to be used outside of the class while still containing all the values it picked up from inside the class? Also, if the $error array already had some values in it BEFORE I used the class, would it be possible to have the class add on to the array, then be able to be used outside the class with every error still intact with it? Hopefully I explained this well enough. I just started using OOP, so If I'm completely going about this the wrong way, please let me know and direct me to the right way I appreciate your help, thanks =]
  3. <input type="text" name="groupname" size="50" value="<?php echo $my_var; ?>">
  4. In the manual it shows an example like this: $handle = fopen("http://www.example.com/", "r"); So I would assume that it should work...what about it doesn't work?
  5. Here is another way. <?php if (is_numeric($age) && $age >= 0 && $age < 100){ echo "You entered a valid age."; } else { echo "ERROR: Invalid Age"; } ?>
  6. Well, you could use javascript. <a href="javascript:history.go(-1)">Go back</a>
  7. You would have to use a HTML Iframe for this. http://www.htmlcodetutorial.com/frames/_IFRAME.html
  8. It means something is wrong with your query. Do this: $result = mysql_query ($query)or die(mysql_error()); That will tell you whats wrong with it.
  9. Well...post your function code. If it just returns a value, you could assign it to a variable. $var = myfunc(); echo $var;
  10. Nope, the way you are doing it is the correct way =] This One: <?php if($flag == 1 || $flag == 2 || $flag == 3) { //do someting } else { //do something else } ?>
  11. <?php if (!isset($id)){ include 'home.php'; } else { include "$id.php"; } ?>
  12. This forum is for "help", not getting people to do things for you. If you would like someone to do this for you, you would best post in the freelance section. Otherwise, you need to attempt to figure it out, and when you get stuck, ask your question. Or you could rephrase your topic as "How would I implement this idea?", instead of "Implement this idea for me". And as rarebit just said, please do get the code for us instead of having us download it just to help you.
  13. Sounds like you need some tutorials, give these a read and see if it clears anything up. http://www.phpwebcommerce.com/ http://www.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart
  14. You would do a query to check if there is a row that already exists with that same information. <?php $query = "SELECT col1 FROM table WHERE col1='$col1' AND col2='$col2' AND col3='$col3' ..."; $result = mysql_query($query)or die(mysql_error()); if (mysql_num_rows($result) < 1){ //there were no rows with the same information, so add it here } ?>
  15. It's because it is a MySQL error, so your not going to get a line number. That is why it is useful to do something like this when performing queries. <?php $query = "SELECT * FROM table"; $result = mysql_query($query)or die("Error:".mysql_error(). "With query" . $query); ?>
  16. Both of those were suggested in the only two posts...was it really necessary to say it again?
  17. Try putting this at the top of your script. error_reporting(0);
  18. Oops, I didn't know you were typing this text in a text field. Use nl2br() BEFORE inserting it into the DB, that will automatically add the <br>'s. www.php.net/nl2br
  19. There may be a way to do with with one line with the date function...I'm not sure. If there is, I don't know how to do it
  20. <?php $date = "yyyy-mm-dd"; list($year, $month, $day) = explode("-", $date); echo "$month/$day/$year"; ?>
  21. Yep, thats probably your only answer. Don't forget to solve the topic.
  22. Why didn't it do much for you? Try these ones: http://www.md5encryption.com/ http://www.md5er.com/
  23. Here is a website you can try out: http://www.md5decrypter.com/
  24. md5 is a one way encryption, you can't reverse it.
×
×
  • 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.