| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 573
![]() ![]() | PHP eval() Hey, Does anyone know how to use the eval function. I wanna output a variable which is stored in a mySQL database but I keep getting this stupid error. Parse error: syntax error, unexpected T_STRING in /home/.eurypides/npsale/vezor.net/certificate.php(39) : eval()'d code on line 1 I'm guessing there's an error in the entry in the database but i removed the text apart from the variable and still nothing. PHP Code: Thanks
__________________ Encenta - Amazon Associates CMS |
| |
| | THREAD STARTER #3 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 573
![]() ![]() | Yeah, it works but the variable just reads $variable.. if that makes sense
__________________ Encenta - Amazon Associates CMS |
| |
| | #4 (permalink) |
| NamePros Member Join Date: Apr 2005
Posts: 117
![]() ![]() | the eval function is not what you should use to output variables. Use print() instead. The eval() function evaluates whatever string you put inside of it as PHP code: print('hello'); //prints to the browser: hello eval('hello'); //is equivalent to typing "hello" as that LINE OF CODE print('$cert=2;') // prints to the browser: $cert=2; eval('$cert=2;') // is the equivalent of typing "$cert=2;" as that LINE OF CODE eval('$cert=2;'); print($cert); //will print the value "2" because it is the same as saying: $cert=2; print($cert); |
| |
| | THREAD STARTER #5 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 573
![]() ![]() | I get what you're saying Mike, but it still displays "$url" in the text. $url is the variable in the database. $certext is the text which the variable is in. Thanks for the help though Mike I think it may be the way I've set it up, I set the variable $url first. 1. $url is set 2. Row ($certext) from MySQL database is taken with "$url" within the text. 3. Need to print $certext.
__________________ Encenta - Amazon Associates CMS |
| |
| | THREAD STARTER #6 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 573
![]() ![]() | I think it may have something to do with my host even. Every page on my website has: PHP Code: PHP Code:
__________________ Encenta - Amazon Associates CMS |
| |
| | THREAD STARTER #8 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 573
![]() ![]() | Get the following error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/.eurypides/npsale/vezor.net/certificate.php on line 38 But thanks anyway
__________________ Encenta - Amazon Associates CMS |
| |
| | #9 (permalink) |
| Senior Member Join Date: Nov 2005 Location: on a oil rig just off Ireland
Posts: 1,408
![]() ![]() ![]() ![]() ![]() | It could be something simple. try this; Code: $certext = stripslashes($row['certext']); eval($certext);
__________________ You design in photoshop, I code into valid XHTML/CSS. Professional PSD, PNG or HTML to tableless XHTML/CSS designs. For more info, send me a PM. |
| |
| | #10 (permalink) |
| NamePros Member Join Date: Oct 2005
Posts: 38
![]() | Sorry I meant: PHP Code: |
| |
| | THREAD STARTER #11 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 573
![]() ![]() | Nah, still no worky. Not to worry. I'll try a different approach. Thanks anyway Scott
__________________ Encenta - Amazon Associates CMS |
| |
| | #12 (permalink) | ||||
| NamePros Regular Join Date: Aug 2005 Location: NY, USA
Posts: 610
![]() ![]() ![]() ![]() ![]() ![]() |
PHP Code:
__________________ ask me about the internet | ||||
| |
| | THREAD STARTER #13 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 573
![]() ![]() | Thanks Jim!
__________________ Encenta - Amazon Associates CMS |
| |
| | #14 (permalink) | ||||
| Senior Member Join Date: Mar 2005
Posts: 4,948
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
PHP Code: | ||||
| |
| | #15 (permalink) | ||||
| NamePros Member Join Date: Apr 2005 Location: Boston, MA
Posts: 26
![]() |
Is your variable called $page or $pagetitle? If this is the code you have in your files, there is no variable named $pagetitle. | ||||
| |
| | THREAD STARTER #17 (permalink) |
| SQLdumpster.com Join Date: Jun 2005 Location: West Sussex, UK
Posts: 573
![]() ![]() | I've been trying to sort this all afternoon. It is still displaying $variable. I've got rid of all the Errors but it is still not working!! It works when there is just $variable; in the database but I need text with $variable in.
__________________ Encenta - Amazon Associates CMS
Last edited by Encenta.com; 04-02-2006 at 02:18 PM.
|
| |