Jump to content

colombian

Members
  • Posts

    79
  • Joined

  • Last visited

    Never

Everything posted by colombian

  1. It is inside the class, and it is being used in that class, but somehow it is still complaining. I'll post the answer here at some point in the next few days. The real function names are descriptive - I've been doing PHP for a while, it's CAKE that was tripping me. Thanks for the responses.
  2. Well good to know, I thought I was going crazy. The function is basically that - however, it's inside a CAKEPHP application. I am just starting to get familiar with CAKEPHP, so there must be something going on that's preventing it from happening. I just tested it outside CAKE and it does work fine... If you know cake... It's inside a controller, I need two very similar functions, so I am using one function and passing the 1 parameter to both. The error is the normal: "Fatal error: call to undefined function....." and it specifies the line number where I am calling function a inside function b. No wonder why google wasn't of help, I'll go delve into CAKE - thanks again,
  3. I am stuck on something terribly simple, but Google isn't helping. How do I call a function inside another function in PHP5? It says the function is undefined. <?php function a() { echo "a"; } function b() { a(); } ?> When calling function b it says a is undefined. I was sure that all function scope was global. Thanks in advance.
  4. Many thanks... I feel very silly - I knew better than that, I started thinking too much, thinking it had something to do with the class. Anyhow - thanks a lot.
  5. I have this class, and with 2 columns and no implicit id, it works fine. However if the MySQL table has column that will by set to auto_increment. In procedural code, that ID is implied and you don't need to specify it in the SQL statement. However, I am getting an error with the class. Maybe the code will make it more clear: <?php class Name { public $Ages; public $Names; public function __construct ($name, $age) { $this->Ages = $age; $this->Names = $name; } public function add_name() { $query = "INSERT INTO name_age VALUES ('$this->Names', $this->Ages)"; $result = mysql_query($query); if (mysql_affected_rows() > 0) { echo "Success!"; } else { echo "<p> Failed</p>" . mysql_error() . "</p> <a href=\"staff.php\"> Return to main page </a>"; } } } $name1 = new Name('John', 28); $name1->add_name(); ?> The code works fine for a two column table with those values - but I am having trouble passing the auto_increment id column... Any help would be greatly appreciated. Thanks
  6. Additional question... I changed this to work with a constructor (just a sample), and it works just as intended - for a 2 column table. However, if I have an auto_num id column as the first one, it complains that the values do not match. My confusion is - typically in SQL queries you don't need to pass a value for the id auto_num column, but it is apparently asking for one - what should I do? Thank you. Code below: <?php class Name { public $Ages; public $Names; public function __construct ($name, $age) { $this->Ages = $age; $this->Names = $name; } public function add_name() { $query = "INSERT INTO name_age VALUES ('$this->Names', $this->Ages)"; $result = mysql_query($query); if (mysql_affected_rows() > 0) { echo "Success!"; } else { echo "<p> Failed</p>" . mysql_error() . "</p> <a href=\"staff.php\"> Return to main page </a>"; } } } $name1 = new Name('John', 28); $name1->add_name(); ?>
  7. Many thanks. This actually helps. I am not writing any large scale projects at the moment - but I want to be ready and learn OOP and start using it, even on small scale ones. Besides, I will likely start working on larger projects very soon. I will play around with this code to see what I can do - thanks again. I will use the constructor though, not sure why you didn't. I understand the use of the function inside the class better, many thanks for taking the time to show me that snippet.
  8. Below is an over-simplification of what I am trying to accomplish. I am having a hard time grasping some of this object oriented programming concepts. I want to know how to go from the class, to the insertion into MySQL. <?php class Stock { public $Symbol public $Price public function __construct ( $in_symbol $in_price ) { $this->Symbol = $in_symbol; $this->Price = $in_price; } } ?> I could just create the object with the data... So we have an html form letting the user pick the symbol and price. They click submit... How do I go from this to insert the data into MySQL OOP style? $stock1 = new Stock($in_pid, $in_price); Do I just insert it like typical procedural way? $sql = "INSERT INTO ... etc" If done this way, the class seems to be a waste, since it is not accomplishing anything. Any help would be appreciated. Thanks in advance.
  9. Security will be about the same - but some pointers: Don't be too specific about the error (you don't want to tell the hacker: "your script to read the security code is right, but you did X wrong" The sequence should be as follows: 1. Make sure the CAPTCHA runs first - and is successful. 2. If successful check the form information. 3. Validate email and content fields against spam attacks with either a regex or throwing an error on CC: BCC:, etc. 4. Now you can store/POST comments. Hope this helps.
  10. Thanks Blue, I believe SQL might not be enough - but hopefully you can shed some light on this: What if the names / addresses are slightly different? Like: John R. Smith, 600 pacificic ave, CA 98342 and John Rogers Smith, 600 SW Pacific AVE, CA 98342 Any ideas? Thanks again.
  11. How could I got about creating a script for deduping a mailing list? (Not email - just Name and address) I know this is broad, I just need some pointers and Google hasn't been helpful. The files can be obtained in CSV, Excel, among others (they can be converted from one to the other easily - so whichever format is easier to dedupe)
  12. Thank you! That did the trick - quick question though. Why does doing $html = (no .= ) cause it to break? More over, why does declaring $html before that loop cause it to break too? I had to declare $html up with the $hour array, and leave as is to make PHP happy. Just trying to understand what PHP is doing here. Thanks again.
  13. Here is my problem, I need this function to be part of a string of outputs. $output = "Html" //etc $output .= "select"; $output .= attending($total_people); However, it only returns 1 of the 9 supposed values for the select box. <?php function attending($var) { $hour = range(1,9); foreach ($hour as $h) { if($var == $h) { $selected = "selected"; } else { $selected = ""; } return "<option {$selected} value=\"{$h}\"> {$h} </option>"; } } ?> If I use "echo" instead of "return" it does give me all 9 outputs, but then I cannot make the form dynimically through the $output variable. Any help is appreciated. Thank you.
  14. You could do 2 things: 1. Integrate the 2 functions (the captcha and the form submission into 1 page). 2. Send your post information from your CAPTCHA the form processing. Integrating the 2 would make more sense, since the CAPTCHA is part of the form. Since the form is submitting for itself - I would place all the code from the for submission page into the else statement I mentioned above. There you would fill in all the $_POST variables to pass them only if the CAPTCHA is successful. So: ?php if ($_POST["submit"]) { if (!$resp->is_valid) { die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } // Would you not need an else here? else { //response is valid. maybe an elseif if you want. // HERE YOU INSERT THE CODE that was on the working form submission page. // Include the $_POST variables for the input. } } ?> Hope this helps.
  15. Well, this is probably Regex territory. You need to determine what particular things are html. Maybe there is a set of 4 that do that. for & and other misc html things like that you can try the htmlentities function. With regular expressions you can find a string with a <br> tag and change it to <br /> and any other things of that nature. On another note - while it is good to follow coding practices (W3C recommendations) you shouldn't worry too much about it - 99% of your users don't know, care, etc. (This comes from someone who uses XHTML 1.1 (strict))
  16. The steps you have taken should keep you spam safe for a while. The hidden form field works ok for bots, and obviously removing the bcc/ etc from the input will help. You could use regular expression to verify the email address, that way you can skip the cc:/bcc/etc part, since those will not pass through a good email regex. You can send your script into the wild of the internet if you testing shows it's working. Also - FYI - you don't need to test for bcc, cc, etc on your for fields in general - you just need to test that against your email field. (Note: I didn't proof the code, just read the comments on what you did and briefly glanced through the code).
  17. It's not clear from the form when the variables are being sent. What it seems to be happening is that when your captcha is validated, the form is happy - and there is no more processing. Make sure you are sending the POST variables on the successful captcha. You have this code: <?php if ($_POST["submit"]) { if (!$resp->is_valid) { die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } // Would you not need an else here? else { //response is valid. maybe an elseif if you want. // send POST variables } } ?>
  18. Hello, I was wondering if someone could point me to some good tutorial or provide some feedback on how to clean a mailing list. I'll probably get an excel file, the goal of the clean includes: 1. Remove duplicates (by full name, address, SS#) 2. Ideally before removing things, it will output a list to confirm things (to make sure that the two "John Smith"'s are different. 3. It needs to match similar addresses (close matches like ave - avenue, etc) I just want some pointers to get this started - I'll likely post at a later time when I have some working code and meet with the people who are giving me the file. Thanks.
  19. It has some weird effects in OS X (10.5) Safari 3.1. Depending on the width of the window the dates (May 2008) disappear and with weird blues around it. (Like 1/4th of the box shows up). However, I wouldn't worry too much about that. The menus look ok - some weird spacing at the top, but it still looks fine. The only thing that I'd say needs improvement is the graphic on the top left. It looks washed out, and not very professional - hope that didn't offend anybody =)
  20. Well, DreamWeaver is not a good PHP editor, it has nothing that makes it stand out for PHP. You might as well be using notepad with color coding. Eclipse with the PDT plugin is a real IDE - DreamWeaver's got nothing on it for PHP development.
  21. Maybe I am missing something - does the RSS feed need to be ISO-8859-1? You can try UTF-8 which helps with spanish accents and more world-wide characters.
  22. If I understand your challenge correctly... You can include as many form fields in the $message. <?php $message = "Thank you bla bla email content "; $message .= "Name: ".$name; //the $name is from the form field that the user submitted $name = $_POST['name']; $message .= "Telephone: ".$phone; //ditto /* etc... just attach all the variables to the message. You will need the <br> /t /n for formatting the email depending on how you want to space the content inside. */ ?>
  23. Sometimes I feel like I'm reinventing the wheel when coding. Be it data validation, classes, functions, etc. I am considering making the switch to a framework. PEAR sounds OK - but doesn't seem very cohesive, and the code doesn't look very optimized (from the few samples I have seen through). Zend sounds more powerful and cohesive (so it "seems" better to me). Truth is - I know very little about these frameworks, and after reading through their respective sites, I didn't get a good feeling for what to expect. I have been programming solo all the time, and never used pre-made packages - I am also fairly new to OO PHP - but I am starting to work with classes. But as classes become more complex, and so does the code to treat them - I feel like I am spending too much time debugging/creating code that these frameworks probably already have, and it will be thoroughly tested by many people. These way I may become more "agile" and focus strictly on the current application, and not all the extra stuff, like personalizing the CRUD. I am looking for honest opinions of developers who have used these frameworks. Thank you.,
  24. I don't really want 1400+ lines of code plus additional packages for this functionality though. My checks through ping functions has lead me to the following error in PHP: ---- Warning: fsockopen() [function.fsockopen]: unable to connect to https://REMOVED.security (Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?) in SERVER_PATH/iframe-test.php on line 51 --- I don't have control of the PHP server - is that a clear indication I won't be able to use the fsockopen function?
  25. It depends on the server and the number of queries. If you are talking thousands and all updated at the same time, by many people, it could cause a slow down. If you are talking a couple of hundred, and only a few people will be performing the change, then it should not be an issue. The two main things you need to look at are: Number of concurrent users Number of changes to the database I am not an expert, but I've done some reading and testing on the subject. MySQL support like 4 billion records per table, so I wouldn't be too worried on that end. (Unless your server isn't that great, and you got tons of concurrent users doing the changes.
×
×
  • 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.