Jump to content

[SOLVED] T_ENCAPSED_AND_WHITESPACE problem


biggerboy

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.