Unsupported Screen Size: The viewport size is too small for the theme to render properly.

Php Variables In Text Fields

forums forums SQLyog Using SQLyog Php Variables In Text Fields

  • This topic is empty.
Viewing 6 reply threads
  • Author
    Posts
    • #9192

      Is there some method for inserting variable names into text fields via SQLyog? I have tried inserting them how I would normally:

      Code:
      this is sometext and here is the “.$variable.” that I would like to appear

      and also by using other methods like dropping the backslashes, quotes etc, but I always get the text $variable appearing instead of the actual value of the variable. Because the page that I am inserting the variables into is php, I have been escaping all quotes with a backslash. URL links were the same, but I found that leaving the backslash out seemed to make it work.

      Any advice?

      Cheers,

      Kieran

    • #19061
      peterlaursen
      Participant

      I am not quite sure that I understand.

      SQLyog has nothing to do with the php scripting language. It does not use php itself and does not “understand” the php language

      But if you want to insert a php variable name as a string like $varaible in a char/varchar/text/blob-field, then just enter that!

      From DATA and RESULT pane you shall neither use escaping or surround strings with quotes – SQLyog does that automatically. SQLyog is a GUI.

      From the SQL-pane escapeng must be there and strings should be surrounded by quotes of course, because in SQL-pane what's is entered must be valid SQL.

    • #19062
      peterlaursen
      Participant
      Quote:
      but I always get the text $variable appearing instead of the actual value of the variable.

      I think I understand better now! Well yes of course you do! A variable name entered in a char/varchar field is just a string. Just like 'peter', 'my dog' and 'this is a very long string' are strings, '$variable' is a string too.

      SQLyog is not a tool for code execution (except for SQL-code). It is a GUI tool for administering MySQL.

    • #19063
      peterlaursen wrote on Aug 29 2005, 02:54 PM:
      SQLyog is not a tool for code execution (except for SQL-code).  It is a GUI tool for administering MySQL.

      [post=”7032″]<{POST_SNAPBACK}>[/post]

      I agree, and realise that. It's not about that though. If I write the sentence “mary had a little goat” in a text field in a database, it will be (at least should be) outputted on screen as “mary had a little goat”. If I have saved somewhere else on the website the php variable $varsentence and assigned it the value “mary had a little goat”, then I would like to enter the following value in the database field:

      the sentence is $varsentence

      If I do this though, when I call the webpage, what I see is “the sentence is $varsentence” and not “the sentence is mary had a little goat”. When I use phpMyAdmin, I have always inserted variables as escaped text (Ie. “the sentence is “.$varsentence) which seems to work, but sqlyog is doing something to it during the save to the database that is making whatever I enter in there literal.

      Again, it's not about the execution of code, but I would assume that what I write into the database field is what would be outputted. It's almost like it's escaping what I enter prior to it being written to the database. Hope this helps a little more.

      Cheers,

      Kieran

    • #19064
      peterlaursen
      Participant

      This is not SQLyog! SQLyog is a MySQl tool and not a php tool.

      A string is a string. SQLyog does not recognize that strings starting with $ is a php-variable.

      I really believe you are messing up MySQL and php! Even MySQL does not recognize what are the actual values of a variable of a php script. In only exist in memory as long as that script runs. It is not in the database.

      It is only inside a php script – and only as long as it runs – that the variable “$varsentence” has the value of “mary had a little goat”. MySQL does not know! In the mySQl database the string '$varsentence' is stored and nothing else. There might be php-scripts, pearl, python, C- and delphi and java programs (just to mention a few!) use that variable for some purpose. How should SQLyog know anything else than the database. It has no chance to know about the values in memory of a script running yesterday!

      To MySQL and SQLyog only the string '$varsentence' exists. What programs use it for (for a varibale name for instance) is not a matter for neither MySQL or SQLyog.

      You simple mess up where database (MySQL) ends and code (php) starts. You can't do things that way! Put “mary had a little goat” in the database and SQLyog will read it!

    • #19065
      peterlaursen wrote on Aug 30 2005, 01:24 PM:
      This is not SQLyog!  SQLyog is a MySQl tool and not a php tool.

      Thanks again for reiterating this. I got it the first time though. I will have a look elsewhere as I feel no matter how I try to explain this, the meaning is being missed. Thanks for trying.

    • #19066
      Ritesh
      Member

      The operation that you are performing can only be done from a programming/scripting language.

      For you reference: http://mysql.scarlet.be/doc/mysql/en/variables.html

Viewing 6 reply threads
  • You must be logged in to reply to this topic.