Jump to content

toplay

Staff Alumni
  • Posts

    973
  • Joined

  • Last visited

    Never

Everything posted by toplay

  1. If you're not doing it yourself (i.e. addslashes), then check your PHP magic quotes setting. See below. "If magic_quotes_runtime is enabled, most functions that return data from any sort of external source including databases and text files will have quotes escaped with a backslash." http://www.php.net/manual/en/info.configuration.php#ini.magic-quotes-runtime http://www.php.net/manual/en/function.set-magic-quotes-runtime.php
  2. What do you mean by "nothing"? An empty string is not considered a NULL value. An empty string and a NULL value are two different values. If you don't want to allow empty cells, then I suggest you code for it (validate data before inserting/updating table(s)). Good luck.
  3. It's clearly documented in the manual found here: http://us2.php.net/manual/en/function.mysql-fetch-array.php It specifies that an associative array be returned (instead of a numeric index). EDIT: Mchl beat me to it.
  4. This is a very specific question on how to go about clearing PHP memcache area from within MySQL stored procedures/functions. I'm not sure if it's possible or not. I'm using PHP 5+ and MySQL 5+. The PHP memcache works fine. I can also use the MySQL memcache to set, get and delete it's own keys within MySQL fine. I'm setting the servers (IP's) used for caching the same on the PHP and MySQL side. However, the problem I'm having is trying to delete a memcache (key) that was created from PHP using MySQL stored procedure and it doesn't delete it. I know what the PHP key is, but when I use it in a SELECT memc_delete('key here'); it returns an integer of 16 and doesn't delete the PHP cache associated with that key. It's like as if the PHP and MySQL caching mechanism have their own specific areas of memory (for caching) even though they both have the same caching server IP's set. Any pointers/help would be appreciated. Thank you. FYI: http://dev.mysql.com/doc/refman/5.0/en/ha-memcached-interfaces-mysqludf.html http://us2.php.net/manual/en/ref.memcache.php
  5. jrws, on the first page load $_POST['submit'] is not set, so it will execute the "else" logic which displays your echo. You want to put that error check/message inside the first 'if' condition after checking if the post variables are empty and display an appropriate error for that. When they're not empty you do the query and if the query fails then give error of login/pswd not good. See now? EDIT: ShaunO beat me to it.
  6. Why do you think it's not working? What is the expect result you want/expect? Sample below is from manual: $result = mysql_query($query); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); }
  7. It gives the error message because you're using a lowercase 's' in submit for the name in the form. Change this: if(isset($_POST['Submit'])){ to this: if(isset($_POST['submit'])){ so it matches your form "name" value: <input type="submit" value="Submit" name="submit" />
  8. You should check for errors after the query to see what's wrong. However, I think it's because "count" is a reserved word in MySQL, so change the column name to something else, or enclosed in backtick marks like this: $query = "UPDATE trk_tracking SET `count` = `count` + 1 WHERE id = " . $totalAds[$counter];
  9. Since you're using just $counter in the "where" clause it will only update id's 0 (which is invalid if ID is an auto increment column) through 11. The variable that you show as containing the array of id values is what you should be using. For example: $query = "UPDATE trk_tracking SET count=count+1 WHERE id = " . $myArray[$counter]; You show 24 values (0-23) in your array, so the "for" loop needs to iterate through that number of entries. For example: for ($counter = 0, $max=count($myArray); $counter < $max; $counter++) { } hth and good luck.
  10. Just put an 'if' before the echo of which ID you want to display. Example: $id_looking_for = 1; // run the query: select * from table_name order by `score` desc // check for errors $rank = 0; while ($row = mysql_fetch_array($result)) { $rank++; // adds 1 if ($id_looking_for == $row['id']) { echo 'Rank: ', $rank, ' Score: ', $row['score']; // put HTML break to end line break; // get out of loop } }
  11. Remove the comma after p_s column. Change this: `p_s`, ) to this: `p_s`)
  12. // run the query: select * from table_name order by `score` desc // check for errors $rank = 0; while ($row = mysql_fetch_array($result)) { $rank++; // adds 1 echo 'Rank: ', $rank, ' Score: ', $row['score']; // put HTML break to end line }
  13. Use this query: select * from table_name order by `score` desc and as you read each row from the table keep a counter and use that to display the ranking.
  14. I follow you on the first part, but lost you on the second part. select * from table_name order by `score` desc or maybe you mean: select * from table_name where `id` = 'x' order by `score` desc # Assuming multiple rows returned Be a bit more clear when posting. Thanks.
  15. LOL ... you're kiddin right? Once again, that's what the "type" column is for in my example!
  16. Yes, what fenway said, but that's why I gave you "type" to show an example of how to add a new value (wherever you want it at).
  17. Wrong, no 'if' at the beginning. Use what I had. This: $color = ($Totalhours > 40) ? 'red' : 'blue'; is the same as this: if ($Totalhours > 40) $color = 'red'; else $color = 'blue'; See ternary operator: http://us3.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary
  18. Something like: (select `to` as email_addr, `subject`, `body`, 'inbox' as type from email_emails where `to` = 'admin@dudeel.com') union all (select `from` as email_addr, `subject`, `body`, 'outbox' as type from email_outbox where `from` = 'admin@dudeel.com')
  19. Retrieve the data, then use PHP to do it: $color = ($Totalhours > 40) ? 'red' : 'blue'; // $Totalhours var is value retrieved from table result echo 'Total hours: <font color="', $color, '">', $Totalhours, '</font>'; // Better to use CSS - this is just an example
  20. The Little Guy, when posting please put more details than just "doesn't work". You're not really giving us enough info on what you do want or expect as output/result. Show us example of data, and example of the result you want/expect. The query in your original post has two tables, but the "where" clause has no join criteria to connect/tie the two tables together. Only you know what the columns are in both table that can match rows together. If you want ALL rows where the "to" column in the email_emails table matches the "from" column in the email_outbox table, then you can get rid of the "where" clause in the query in my previous post. Using the "to" to match a "from" in the other table doesn't make much sense to me, but I'm using it because that's all you posted and the only thing I have to go on. Ask yourself, what is the common data from both tables that can connect them together?
  21. You might want to do a repair on the table(s) just in case. How are you guaranteeing that you're the only person who has access to the delete functionality? It might have to do with your code and how people can inject SQL. Make sure you're using mysql_real_escape_string() or mysql_escape_string() on values before inserting/updating/deleting in table. Forum members won't be able to help much without seeing your actual code.
  22. Ask yourself which is the common column in both tables that will tie the two tables together? select * from email_emails e join email_outbox o on e.to = o.from # specify the column link between the two tables where e.to = 'admin@dudeel.com'
  23. You forgot to post the $updatequery value just before the mysql_query() so we can see what the actual query with data is. You probably have a quote in your data and you should be escaping the data users enter before trying to insert/update your table (see note in my first post).
  24. So, add a group by at the end then. group by some_column_name # Use something relevant to query
×
×
  • 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.