Well, I'm trying to install a news value
'thing' and I'm the newbiest of newbies at running queries as you can get. Upon running, I get an error.
INSERT INTO setting (settingid,settinggroupid,title,varname,value,description,optioncode,displayorder) VALUES (NULL,2,'News','$news','','Insert forum news here...','textarea','7');
^^Thats^^ the quiery, and I get an error that says soemthing is wrong at the end of line one begining from $news. Help is appreciated.
New Comer, with a Question.
Moderator: General Moderators
possible solution
it is probalby trying to subsitiute $news with a value and can't.
It looks like you want to save $news as a literal and not its value.
Try escaping the $ like \$news.
this should escape the $ sign and save it as a literal.
the other thing you could do is strip of the $ and just save news as you know what the column is and can add the $ back when ever you need it as a variable.
of coure why are trying to save a variable name in your db anyway
It looks like you want to save $news as a literal and not its value.
Try escaping the $ like \$news.
this should escape the $ sign and save it as a literal.
the other thing you could do is strip of the $ and just save news as you know what the column is and can add the $ back when ever you need it as a variable.
of coure why are trying to save a variable name in your db anyway
By putting $news in single quotes it will not try and pass the variable $news with the result being it will try and insert $news as a string value into the record. either use double quotes "$news" or concatenate the string.
That might or might not be the problem, do you want to post the code and the actual error message so we can get a better idea.
That might or might not be the problem, do you want to post the code and the actual error message so we can get a better idea.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you're doing this through PHP:
You should have the string in double quotes and then you don't have to escape any of the single quotes. The only thing you need to escape is the dollar sign.
Mac
Code: Select all
$sql = "INSERT INTO setting
(settingid, settinggroupid, title, varname, value, description, optioncode, displayorder)
VALUES (NULL, 2, 'News',' \$news', '', 'Insert forum news here...', 'textarea',' 7')";
@mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');Mac