SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php + mysql text field error

    I've been having this problem for a while and I cant find a fix around it now matter how hard I search. Basically in the old mysql I could assign a value to a text field automatically or I could just leave it blank now all that has changed.

    When i do a query such as insert into `whatever` (`column1`) values ('whatever')
    It will not work if I have any other columns which are text fiends in the same table. So for example column2 is a text field and column3 is a varchar but because I didn't specifically assign values to them during my query, the entire query will fail. Is there any way around this. It becomes a big issue if I wish to change my database structure later. Adding just 1 extra field will make my entire site unable to function until I change every single insert query. There has to be a way around this, I'm almost 100% sure that the guys behind MySQL are not stupid enough to miss this issue.

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Perhaps if you show the schema for a typical table you are having problems with, and an example sql statement that typifies this behaviour along with the error it throws, then that would provide a nicer illustration.

    I suspect this is at its core this is an SQL question, but probably affects many PHPers.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    Perhaps if you show the schema for a typical table you are having problems with, and an example sql statement that typifies this behaviour along with the error it throws, then that would provide a nicer illustration.

    I suspect this is at its core this is an SQL question, but probably affects many PHPers.
    I did provide an example. Read my post again and you'll see it. I provided an insert example and said if I have any other columns that are a text field asides from the one that I'm trying to insert. Nothing happens and I cant post. I did some extensive research. I'm not sure if this is true but apparently its a windows bug and on linux it gives a warning and processes the request by giving the text field a blank value but on windows it gives an error and doesn't process the request.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,248
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by ArchAngel_ View Post
    ... but because I didn't specifically assign values to them during my query, the entire query will fail. Is there any way around this.
    make sure those other columns have a DEFAULT value

    if you post the results of a SHOW CREATE TABLE i can comment further
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    make sure those other columns have a DEFAULT value

    if you post the results of a SHOW CREATE TABLE i can comment further
    A default value can not be assigned to a text field that was the main problem I was having. In mysql 4.0 this would be solved by automatically assigning a blank value; and from what I read online, lynux will give a warning but wont stop the query and will also assign a blank value, this however isn't the case with windows. I'm not too sure if this is true as I do not use linux.


Bookmarks

Posting Permissions

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