Results 1 to 11 of 11
  1. #1
    Join Date
    Dec 2007
    Location
    Rivne, Ukraine
    Posts
    6

    Unanswered: UPDATE with PHP works wrong

    All queries like:

    Code:
    UPDATE ua_content SET id_category_c='2', 
    title_content='some content', 
    preview_content='bla-bla-bla', 
    text_content='long bla-bla-bla', 
    type_content='0', keywords_content = '' 
    WHERE id_content='4'
    from PHP script set all data in row to empty values for string data and 0 for integer data.

    This query, executed from phpMyAdmin, works propertly.

    Database Server MySQL 5.0
    Encoding cp1251

    PHP code:
    Code:
    $sql="...";
    ...
    print($sql);
    if (!($r=mysql_db_query($nameDB, $sql, $lnkDB)))
      print(mysql_error().' ->'.$sql);
    Please help me.
    Last edited by Standman; 12-11-07 at 11:06.

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by Standman
    set all data in row to empty values for string data and 0 for integer data.
    I don't see any integer data in your UPDATE statement.
    You have used single quotes for all values, that means they are all character data.

    Does the statement work properly when beeing run without PHP? If that is the case, you should post this to the PHP forum.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Standman
    This query, executed from phpMyAdmin, works propertly.
    thread moved to php forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Dec 2007
    Location
    Rivne, Ukraine
    Posts
    6
    Quote Originally Posted by shammat
    I don't see any integer data in your UPDATE statement.
    You have used single quotes for all values, that means they are all character data.
    id_content is integer field. Single quotes used for safety script

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    "safety script" ??
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Dec 2007
    Location
    Rivne, Ukraine
    Posts
    6
    Quote Originally Posted by r937
    "safety script" ??
    Sorry, speak English bad.
    I mean that single quotes used to protect from SQL-injection.

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    your english is fine

    single quotes do not prevent sql injection
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  8. #8
    Join Date
    Dec 2007
    Location
    Rivne, Ukraine
    Posts
    6
    Quote Originally Posted by r937
    your english is fine
    single quotes do not prevent sql injection
    Thank You
    I use single quotes with complex of another facilities to prevent.

    But in this case a basic problem consists in wrong results UPDATE-queries
    Before I used MySQL server 4.0. But now my dstabase server is MySQL 5.0 and my script don't works propertly.

  9. #9
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    is it a mysql problem or a php problem?

    you did say that the query works properly in phpmyadmin

    therefore it's a php problem, and mysql 5 is not the cause
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  10. #10
    Join Date
    Dec 2007
    Location
    Rivne, Ukraine
    Posts
    6
    Quote Originally Posted by r937
    is it a mysql problem or a php problem?
    I don't know

    Quote Originally Posted by r937
    you did say that the query works properly in phpmyadmin
    therefore it's a php problem, and mysql 5 is not the cause
    I think, that problem is in MySQL, because I'm wrote CMS script, that works properly in MySQL 4 Server. When I began to work with MySQL 5 Server, problems have a place. Tonight I'll test this script in MySQL 4.0 Server and will say results tomorrow.

    But I don't think that problems with UPDATE will be in older MySQL servers.

  11. #11
    Join Date
    Dec 2007
    Location
    Rivne, Ukraine
    Posts
    6
    I found the reason of the problem.

    PHP and MySQL scripts works good.

    There was troubles with Firefox web browser and refreshing the page.

    Thank all!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •