Jump to content

mem0ri

Members
  • Posts

    110
  • Joined

  • Last visited

    Never

Everything posted by mem0ri

  1. Thanks to both posters... ...no, a new object does not need parentheses... ...I also agree that opening up an entire __get and __set can be messy...but I did so on this class because it exists purely for the purpose of taking received variables, manipulating them, and then placing them into the only class-global variables that exist for the express purpose of getting and setting those array values within the page. The problem was actually... if(array_key_exists($property, $this->headers)) return $this->headers($property); needed to be if(array_key_exists($property, $this->headers)) return $this->headers[$property]; Talk about a headache over nothing...just found that after leaving the project and coming back and scratching my head a bit.
  2. Server: PHP 5.2.0 Class runs without error. Page runs without error. When I try to reference -any- variable acquired through the __get function, however, the page fails and load stops. reference in page: $data = new ReceiveComms; //takes $_GET and $_POST and $_HEADER variables and places them in arrays. echo $data->obj; Class function: public function __get($property) { if(array_key_exists($property, $this->headers)) return $this->headers($property); else if(array_key_exists($property, $this->data)) return $this->data($property); else return NULL; } Interesting thing is...if I print_r either $this->headers or $this->data, they have all of the appropriate values...and $this->data has the 'obj' key... ...anyone else experience similar problems? Any solutions?
  3. I have a page in which there is an option list that looks something like: <option value="527">3m</option> And I need to fill the text value (the 3m) to a hidden input tag like so: <input name="size" id="size" type="hidden" value="3m" /> So far...I've managed the following JavaScript code <SCRIPT type="text/javascript"> var selects = document.getElementsByTagName('option'); for(i=0; i < selects.length; i++) { if(selects[i].hasAttribute('selected')) document.getElementById('size').setAttribute('value', selects[i].innerText); } </SCRIPT> The problem line is: document.getElementById('size').setAttribute('value', selects[i].innerText); Help me out please?
  4. You'll actually want to look into "relational database tables". There are several good articles on the web about them. As a previous reply mentioned, the a great way to think about it is "does all this information fit easily on one row". You might also want to ask yourself "is this information likely to be duplicated over and over again within my rows". If so...and dependent on the complexity of the information...you'll also want to build a separate table for that information. If you take some time to build your database tables correctly, you will save a myriad of headaches down the road.
  5. I may have missed it (there was a long bit of code there)...but in the only location I see anything removed (removeItem), you remove only from the database...not from the session...you would actually need to remove from the session as well in order for the session variable to update.
  6. Instead of checking if $partnum = $part['PartNum'] you need to check if you got an array result at all. if($part == FALSE) would do the trick.
  7. Two possible problems: 1--Your MySQL doesn't like the space you're including between MAX and (ordid)...so try MAX(ordid)...yes, it's ridiculous, but I've seen more ridiculous things. 2--Your version of MySQL does not support the MAX function (which is what the error seems to be saying). At that point, you could always do something like: SELECT id FROM order ORDER BY id DESC LIMIT 1[code=php:0] ...which will give you the highest order number on the table. Then...just add 1 before display.
  8. You need to replace your 2nd INSERT with an UPDATE statement: UPDATE (table) SET col1 = 'var1', col2 = 'var2'... WHERE col = var;
  9. Personally, I wouldn't change the entire connection, only switch databases within the same connection. mysql_select_db() is the function... ...that way...with the function you can start it with mysql_select_db($x) and then go back to mysql_select_db($y) at the end... ...unless you're connecting to two completely different db servers?
  10. It is easy...you just need substr($str, 0, 3)
  11. You're not off by much...you don't want to loop through and recreate a new <select> box with every result (at least I hope not)...so you really only want to loop through the <option> part of the code...example //YOUR EARLIER CODE HERE <tr bgcolor="' . $row_color . '"> <td width=250 valign=top> <p class=\"small\"> <form><select name="dmalist"> <option value=''>- Select -</option> <?php while($results = mysql_fetch_array($sql_address)){ ?> <option value="view_records.php?station=' .$results['station_id'] . '> formSelected( $HTTP_POST_VARS[ "dma_id" ], [ "station_id" ] ); </option> <?php } ?> </select></form> </p> </td> </tr>'; //REST OF YOUR CODE HERE ...hmmm...o.k...that was really dirty code alteration I posted...changed it...gah...teach me to post really fast in reply...
  12. Add a loop that goes something like... while($row = mysql_fetch_array($result)) $total_charge += $row['charge_amount']; ...since your query is looping (ouch), I'll assume that you're echoing the DB results in each loop...so if you just echo-out total charge during that process and then reset it to 0 with the next loop...you should be fine.
  13. Just a general word of advice... I see lots of people trying to store text-dates with their applications...timestamps are almost always a better option. It's very easy to convert them back into "readable" format for display and they're very easy to compare/manipulate/etc.
  14. You need to put a WHERE clause on your DELETE statement for SQL or you're going to delete all entries in the coupon table. The WHERE clause should clearly identify one (or several) rows as those you want to have deleted. From the block of code you have given, it is impossible to guess what those identifiers might be.
  15. You say the data stores in the SQL table correctly? In my experience, that usually happens when you don't quote your strings correctly with an INSERT or UPDATE statement (it'll cut off at first space when going into the table...thus it gets only the first part when you display).
  16. You'll just want to add some CSS code when you display the image...somethin' like IMG { border:1px solid #000000; }
  17. How about isolating line 67 with a few of the lines before and a few of the lines after...and posting what, exactly, the error is?
  18. How about something like $query = "SELECT id FROM time WHERE (fldETime > '$startTime' AND fldETime < '$endTime') OR (fldSTime < '$endTime' AND fldSTime > '$startTime')"; It's not a query I've tried...but I don't see why it wouldn't work.
  19. Sounds a lot like what happens to me when I'm encoding (through md5 or other encoding) a password on account creation but then forget to encode the $_POST[] result on login... ...is the password encoded on your database? Also...instead of if ($numrows == 1) try if($numrows != FALSE)
  20. Wouldn't $x /= 100; work? So long as you're not hard-typed to an integer, it should auto-convert to a float. (at least it always does for me)
  21. If you'd like to post code maybe we can help clean up some of your queries? You really shouldn't need to have more than a couple of queries on any given page.
  22. It really depends on how you have your data organized. Are you keeping timestamps? Are you databasing each hour? How are you storing your data? Once we know how you are storing it, we'll be able to more easily tell you how to compare the datablocks to check for overlap.
  23. As far as I can see, yes, that should work...and yes, $text is just a variable holding all of your text.
  24. mysql_real_escape_string You'll need to have a database connection already open (though I assume that'll be the case as you mentioned you'll be inserting it into a database), and then you'll want to run: $text = mysql_real_escape_string($text); It will replace all special characters with escaped versions that store appropriately in MySQL.
×
×
  • 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.