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'"; Quote Link to comment 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 Quote Link to comment 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'';?> Quote Link to comment 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']}' Quote Link to comment 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']."' Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 24, 2007 Share Posted October 24, 2007 post your recent code? Quote Link to comment 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''; Quote Link to comment 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'';?> Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.