Inserting to database

jolza

New Member
Heyy

What im trying to do is make a form so that someone can post there web code into a database so it can be showed on different pages ect

I have it all working fine
But

when i put code in like with certain tags it has an error :
eg

echo 'hello world';

then use query to insert to my database i get an error saying the syntax is wrong

Think its due to this ;
its getting the syntax of the posted code mixed to that of the actual code

any help would greatly be appreciated
 

DOAWebDesigns

New Member
How are you trying to use the inserted code?

Heyy

What im trying to do is make a form so that someone can post there web code into a database so it can be showed on different pages ect

I have it all working fine
But

when i put code in like with certain tags it has an error :
eg

echo 'hello world';

then use query to insert to my database i get an error saying the syntax is wrong

Think its due to this ;
its getting the syntax of the posted code mixed to that of the actual code

any help would greatly be appreciated


Are you trying show the code as plain text on the other pages or trying to excute what's been inputted?
 

jolza

New Member
im trying to get users to insert the code from a form, which is then sent
to a database, so that later it can be shown on a page

So not actually using this code as any part of my site
 

DOAWebDesigns

New Member
im trying to get users to insert the code from a form, which is then sent
to a database, so that later it can be shown on a page

So not actually using this code as any part of my site

Ok I'm trying to follow you :).
When you say display on a page later, are you saying that you want it to display Hello World or <? echo 'Hello World' ;?> ?
 

jolza

New Member
I'm just using this as an example,
So that users can input web code so that it can be shown if they are in need of help. Its just that some code wont get inserted into my database.

Its only when you put certain syntax into the input form, i think it takes it as the actual script then errors out.

Eg
I have a form where you input web code

$code = $_POST['code'];
mysql_query("INSERT INTO code_discussion ( code ) VALUES ( '$code'");

if someone would happen to input this code
echo 'Add more code';

then it would error out
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'add more code';

I think its due to the '' or ;
that its using the code from the variable $code and using that as the script
if you know what I'm trying to say
 
Top