Jump to content

Recommended Posts

When i try to insert some variables into a mysql database from php

 

php code:

$sql="INSERT INTO posts (user, post, order)

VALUES

('$name','$post_put','$num')";

 

I get this error:

Error, please report to harris(webmaster): 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 'order) VALUES ('harris','

test

','2')' at line 1

 

if i use this code:

$sql="INSERT INTO posts (user, post)

VALUES

('$name','$post_put'')";

 

it works. can someone please tell me what i am doing wrong when i add on order. Yes the order columb in the mysql db is made and if i echo $num i get the number i want to go into the database, just something is wrong when it tries to put the # into the db

ok thanks for the help it worked also now i have a new problem. I am making a website where i want some areas to ignore html/php and just display the code, so i put <xmp> </xmp> around the code, but i want to still allow <br />'s. without going <xmp> code </xmp><br /> <xmp> morecode </xmp> is there a way i can have php search the file and replace <br /> with </xmp> <br /> <xmp> so i dont have to type extra lol. the <xmp> code <br /> morecode </xmp> is displayed using echo "$post";

so for example if i have the following script

 

<?php

$post = " <xmp> Welcome to ForumZ <br /> We host your forums! <br /> Have a nice day!!! </xmp>";

echo $post;

?>

 

how would i make it find the <"br />" and replace them with "</xmp> <br /> <xmp>" without the quotes. You dont really need to know what <xmp> is, i just need to know how to make it find and replace in the code.

for those of you who dont know anything in <xmp> </xmp> will have it's html ignored, so if you are writting a website or something you can show coding by saying <xmp> <br /> </xmp> and on a normal website you wont see a line down but instead the code

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.