forums › forums › SQLyog › Using SQLyog › Php Variables In Text Fields
- This topic is empty.
-
AuthorPosts
-
-
August 29, 2005 at 1:23 am #9192kierangarbuttMember
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 appearand 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
-
August 29, 2005 at 1:49 am #19061peterlaursenParticipant
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.
-
August 29, 2005 at 1:54 am #19062peterlaursenParticipantQuote: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.
-
August 29, 2005 at 11:32 pm #19063kierangarbuttMemberpeterlaursen 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
-
August 30, 2005 at 12:24 am #19064peterlaursenParticipant
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!
-
August 30, 2005 at 1:19 am #19065kierangarbuttMemberpeterlaursen 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.
-
August 30, 2005 at 4:16 am #19066RiteshMember
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
-
-
AuthorPosts
- You must be logged in to reply to this topic.