Jump to content

toplay

Staff Alumni
  • Posts

    973
  • Joined

  • Last visited

    Never

Posts 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. 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

     

     

  4. 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.

     

  5. 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);

    }

  6. 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" />

     

     

     

  7. 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];

     

     

  8. 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.

     

     

  9. 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

        }

    }

  10. // 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

    }

     

  11. 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.

     

     

  12. 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

     

     

     

     

     

  13. 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?

     

     

  14. 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.

     

  15. 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).

     

     

×
×
  • 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.