SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2002
    Location
    Pittsburgh PA
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Text does not arrive in table

    I'm in a debug mode.

    I have a variable, $NewText, which creates a string from other variables like so:

    $NewText = ( $Title_Of_Event ." </b> - ". $SpeakerText);

    This works nicely and I can then print it with no problem.

    Before sending it to mysql I have:
    $NewText = addslashes($NewText);

    However when it comes to passing it to mysql this variable is lost somewhere. Many other variables make the trip so my general statements are ok.

    mysql commands are of this type:
    $query = "INSERT INTO Events ( SqlEventStart, NewText )
    VALUES ('$SqlEventStart','$NewText' )";

    When I browse the database using phpAdmin the NewText field is empty.

    Any ideas, personal horror stories, or perhaps incantations that work for you?

    Alex

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well first off depending on the version of mysql you may not have to add slashes as php and mysql do it together.

    As for the other. Echo $query and take the line EXACTLY and move to the command prompt. You will find a couple of things this way.

    1 The variable may be to large for the column
    2 wrong type
    3 Something is going wrong between the joining of the words and the query
    OR
    3 something is going wrong in the db.

    This will help narrow down the possibilities.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2002
    Location
    Pittsburgh PA
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Maelstorm,

    I thought that addslashes was needed. Then I don't understand why is there so much crying and lamentation about addslashes and magic quotes on the Forum pages? ;-)

    I did an echo/print of $query and all the information was present -- except for NewText where there was an empty pair of single quotes.

    1) I am unfamiliar with any restriction on the length of variable names, but in any event I have others that are much longer and they don't cause a fuss.

    2) The type is text. I think that is correct.

    3a) The action is PHP_SELF and all the other variables make the trip between the major segments. The last command involving this variable is:
    print ($NewText)
    Which acually does print the string correctly.

    3b) How could I detect if the db is wrong? Since everything else is working it doesn't seem likely.

    Other ideas?
    Alex

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You probably have a typo in your code somewhere.


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
  •