06-11-2004, 12:44 PM | #1 (permalink) | |||
Professor of Drinkology
|
[mySQL] Script file failing HELP!
I'm trying to use a script file to insert information into a table called, pages, belonging to the database, brenthoard. This is probably something n00bish ...
Here are the table fields: Quote:
Quote:
Quote:
__________________
Blah. Last edited by tritium; 06-11-2004 at 12:53 PM.. |
|||
06-11-2004, 12:56 PM | #2 (permalink) |
Crazy
Location: Salt Town, UT
|
Watch your quoting
Watch your quotes. You need to put anything text-wise into a database enclosed in quotes. But when it hits another set of those quotes, the quoting stops, and it tries to go back into plain old sql mode.
So everywhere in your actual text, you need to escape all of the " with \" (most systems have a way to do this, like php's addslashes() ) Example: Before: INSERT INTO pages VALUES ( 1, "<SCRIPT LANGUAGE="JavaScript"> <!-- Begin After: INSERT INTO pages VALUES ( 1, "<SCRIPT LANGUAGE=\"JavaScript\"> <!-- Begin |
06-11-2004, 01:15 PM | #3 (permalink) | |
Professor of Drinkology
|
I went through and changed all the single quotation marks to the \" and received a series of errors:
Quote:
__________________
Blah. |
|
06-11-2004, 09:12 PM | #5 (permalink) |
Banned
|
One possible quick fix...replace all double quotes in the code itself with single quotes and then wrap the code in double quotes. You have an awful lot of special characters in your javascript/html, so you have to be careful to segregate SQL significant characters from your code.
Edit: the suggestion to escape any double quotes with a "\" (ie - \") should work, but only if you leave the outermost, wrapping quotes alone...for instance: "<SCRIPT LANGUAGE=\"JavaScript\">...</table>"); Last edited by cthulu23; 06-11-2004 at 09:24 PM.. |
06-13-2004, 09:50 PM | #6 (permalink) |
Professor of Drinkology
|
I'll post a link to the script tomorow. I wound up using ' instead of " ... this allowed me to input the text to the database, but trashed my javascripting...
I'll need to figure out why the /" thing doesn't work correctly.
__________________
Blah. |
06-13-2004, 10:54 PM | #7 (permalink) | |
Rookie
Location: Oxford, UK
|
Quote:
__________________
I can't understand why people are frightened of new ideas. I'm frightened of the old ones. -- John Cage (1912 - 1992) Last edited by cliche; 06-14-2004 at 07:36 AM.. |
|
Tags |
failing, file, mysql, script |
|
|