biggerboy Posted October 23, 2007 Share Posted October 23, 2007 I have what is below and when I run it, it returns T_ENCAPSED_AND_WHITESPACE $query = "insert into images set realname='$filename_orig', user='$username', size='$filesize', used='$date', type='$filetype', desc='$desc', ip='$_SERVER['REMOTE_ADDR']', private='1', report='0'"; Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/ Share on other sites More sharing options...
High_-_Tek Posted October 23, 2007 Share Posted October 23, 2007 You either need to change all the 's in your query itself (not counting the two ' that signal the beginning and end of a string) to "s or escape them Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/#findComment-376575 Share on other sites More sharing options...
darkfreaks Posted October 23, 2007 Share Posted October 23, 2007 <?php $query = 'insert into images set realname='.$filename_orig.', user='.$username.', size='.$filesize.', used='.$date.', type='.$filetype.', desc='.$desc.', ip='.$_SERVER['REMOTE_ADDR'].', private='1', report='0'';?> Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/#findComment-376583 Share on other sites More sharing options...
roopurt18 Posted October 23, 2007 Share Posted October 23, 2007 ip='$_SERVER['REMOTE_ADDR']' The above snippet is what is causing the problem. You have single quotes that denote strings to MySQL but then you have other single quotes that denote the index into the $_SERVER array. It is always recommended when embedding variables into double-quoted strings to enclose them in curly brackets. ip='{$_SERVER['REMOTE_ADDR']}' Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/#findComment-376586 Share on other sites More sharing options...
teng84 Posted October 23, 2007 Share Posted October 23, 2007 you can also use the concatenator ip='".$_SERVER['REMOTE_ADDR']."' Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/#findComment-376589 Share on other sites More sharing options...
biggerboy Posted October 24, 2007 Author Share Posted October 24, 2007 Tried all of those items posted and still got the error. Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/#findComment-376673 Share on other sites More sharing options...
teng84 Posted October 24, 2007 Share Posted October 24, 2007 post your recent code? Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/#findComment-376675 Share on other sites More sharing options...
biggerboy Posted October 24, 2007 Author Share Posted October 24, 2007 What part would be most helpful? Here is the last one I tried. Could it be something with the strings that are causing it? $query = 'insert into images set realname='".$filename_orig."', user='".$username."', size='".$filesize."', used='".$date."', type='".$filetype."', desc='".$desc."', ip='".{$_SERVER['REMOTE_ADDR']}."', private='1', report='0''; Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/#findComment-376676 Share on other sites More sharing options...
darkfreaks Posted October 24, 2007 Share Posted October 24, 2007 <?php $query = 'insert into images set realname='.$filename_orig.', user='.$username.', size='.$filesize.', used='.$date.', type='.$filetype.', desc='.$desc.', ip='.{$_SERVER['REMOTE_ADDR']}.', private='1', report='0'';?> Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/#findComment-376677 Share on other sites More sharing options...
biggerboy Posted October 24, 2007 Author Share Posted October 24, 2007 Getting unexpected T_LNUMBER where the private and report entries are now. Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/#findComment-376694 Share on other sites More sharing options...
teng84 Posted October 24, 2007 Share Posted October 24, 2007 remove the single quote around those numbers or you may want to replace it with " double quote Link to comment https://forums.phpfreaks.com/topic/74510-solved-t_encapsed_and_whitespace-problem/#findComment-376696 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.