Jump to content

s0c0

Members
  • Posts

    422
  • Joined

  • Last visited

    Never

Everything posted by s0c0

  1. Hello, I receive the following FATAL error: json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument Here is the code: echo json_encode($cart->get_products()); get_products returns an array even if its just an empty array. Does anyone have any experience with this or seen it before. Couldn't find any solutions through googling around and am wondering if I need pass the encoded data through something like http://www.php.net/manual/en/function.utf8-encode.php Please advise.
  2. data is not very sensitive, going to use a rotating character algorithm, never mind.
  3. I need a simple two-way encryption algorithm that does not require mcrypt. What did PHP use for 2ways prior to mcrypt? The reason for this is installing mcrypt on our production server requires a recompile of PHP and I'm not keen on doing that on a production server. Security and bit-length of the algo is not that important. Please advise.
  4. That cannot be the entire code because I don't see a query...you should invest in a book.
  5. s0c0

    Query Help

    If I understand what you are looking to accomplish here is some pseudo code that will help. Avoid looping through a result set and issueing a query each time. Instead utilize the IN and NOT IN operators in this case. $q1 = "SELECT storyId FROM ratings WHERE username='".$session->username."'; // store q1 in an array lets call that $storyArr $q2 = "SELECT username FROM ratings WHERE username NOT IN ('$session->username','Anonymous') AND storyId IN (".implode(',',$storyArr).")"; // $q2 is what you need and will have a list of compatible users...
  6. Marked solved for impossibility...back to the drawing board, thanks.
  7. If you are having difficulty with this it may behoove you to pick up a beginners MySQL/PHP book. Alls you are doing is taking a POST value, doing a query against the database, multiplying the two values, and displaying the result to the user.
  8. I am not sure why you would want to, but an inelegant solution would be to use the substr() function to remove the first character if the first character is equal to zero.
  9. I think I will have to write some code or a very fancy query to accomplish this, but thought I would ask. We have a log that stores changes to tables. The field_name is the column name, the name_table is the table name, and the name_pk is the primary key. id_row is the value for the primary key and the snapshot is what the value was. I am able to select the snapshot, but within the same query I would like to return what the current value is. Below I attempt using udv's within a sub query, but I don't believe MySQL will support this. Of course I try to do it without code and without multiple queries first, prospects look dismal. Any suggestions? SELECT @field:= field_name, id_row, change_type, @tbl:= name_table, @pk:= name_pk, snapshot, (SELECT @field FROM @tbl WHERE @pk = log_record_change.id_row) as current_value FROM log_record_change INNER JOIN log_field_change ON log_field_change.id_record_change = log_record_change.id INNER JOIN log_table ON log_table.id = log_record_change.id_table WHERE log_record_change.id_change = 36
  10. True that might be overkill. I learned how to program and about mysql from this book http://www.amazon.com/PHP-MySQL-Web-Development-4th/dp/0672329166/ref=sr_1_1?ie=UTF8&qid=1291051671&sr=8-1 albeit that was 5 years ago. Still gave me a solid start and was easy enough to read for a tech savy network admin with limited programming/database experience.
  11. Did you try googling that error? Did you see if there is more information in your php/iis error logs? Sorry, most on here likely run the LAMP stack.
  12. Hi is just asking for recommendations for reading material... not specific help. Read High Performance MySQL, its my fav and written my the guys over at mysqlperformanceblog.com. Make sure you get the most recent edition possible. I've got some pretty sweet information on my blog as well.
  13. I assume the slow down is in LOOKUPS. Pikachu is correct, 35k or even 10x that amount is nothing for a database. Please post your create table syntax and an example of a typical record in there.
  14. I'm with fenway on this, why do you need to do this? For whatever reason you would want to do this, you could put this logic in your applications code.
  15. Interestingly enough High Performance MySQL has a chapter on query/index optimization that has an example VERY similar to your post. Just found that kinda interesting.
  16. Umm... SELECT * FROM my_table WHERE (age = '18' AND gender = 'M') OR (age = '18' AND eyes = 'Blue') Does something like this not work?
  17. I believe your problem is this. For a value you put in 25 50. That is not a valid integer. To put in something with a space it would be a varchar and therefor you would need to put in with quotes on each side. I don't know your schema, but that is your problem. To do an insert assuming start/finish are INTS do as follows: INSERT INTO goals (start,finish) VALUES (25,50); That will insert a single row. To do multiples: INSERT INTO goals (start,finish) VALUES (25,50),(25,100);
  18. Yeah, javascript debugging is rough. Try enabling the script debugger in IE and see if it gives you a line number or a reasonable sounding error message.
  19. savagenoob is a prick, i would try searching google or looking at adobe's site, there has to be a solid community for it. Maybe even stackoverflow.com
  20. This is really a question for the mysql forum. Try looking into using a GROUP BY. Information on that can be found by googling: mysql group by. If that does not help, then post your tables create syntax and I'll look at it later.
  21. 1. Yes 2. It has no name, you could give it a name only this way: $theNameOfTheArray = $model->getBookList
  22. I'm not good with terminology but in your first example the variable $allbooks can only be accessed within that function since it was only defined in that function. To access it outside of the method it would need to be defined as a data attribute of the class Model. So yes, $this->allBooks would be accessible from the object.
  23. Needs to be: if(!isset($value) || $value == "") You used a bad equality operator, common mistake. I would also use empty($value) as $value will always be set. Also wrap you foreach in an if(is_array($_POST['menuitem'])) as an unforseen error may pass over a non-array and you will want to account for that, else you'll get a warning looping through it.
  24. Nevermind the last reply. I have got it working: CREATE TRIGGER pHash BEFORE UPDATE ON products FOR EACH ROW SET NEW.model_hash = crc32(NEW.products_model);
  25. Can you give me a hint on the syntax here? I tried this: CREATE TRIGGER pHash BEFORE UPDATE ON products FOR EACH ROW BEGIN SET NEW.model_hash = crc32(NEW.products_model) END; Did not work.
×
×
  • 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.