Jump to content
xisto Community
Sign in to follow this  
ghostrider

Mysql Query

Recommended Posts

theres a bug somewhere in this query and i can't seem to find it. does anyone else see it?

$query = "insert into templates (tuid,tname,tdescription,template,archivedefault) values (1,'Sample Archive Template','A sample archive template that only shows the name of the article with a link to the default article viewer.','<a href='viewarticle1.php?aid=[id]'>[articletitle]</a>',FALSE)";

Share this post


Link to post
Share on other sites

$query = "insert into templates (tuid,tname,tdescription,template,archivedefault) values (1,'Sample Archive Template','A sample archive template that only shows the name of the article with a link to the default article viewer.','<a href='viewarticle1.php?aid=[id]'>[articletitle]</a>',FALSE)";

 

the whole code is correct for PHP but datebase will have problem parsing your query becuase of the single quotes used in the 2nd to the last value.

 

and by the way should there be a dollar sign in id and article? like $id, $article?

Edited by saga (see edit history)

Share this post


Link to post
Share on other sites

each element that is add to your table is separated by a aposthrophy, so you can't have them in your link unless you add an escape character (which in php is \ ) before the apostrophy in the link (as Saga said).

$query = "insert into templates (tuid,tname,tdescription,template,archivedefault) values (1,'Sample Archive Template','A sample archive template that only shows the name of the article with a link to the default article viewer.','<a href=\'viewarticle1.php?aid=[id]\'>[articletitle]</a>',FALSE)";

This code replaces [id] and [articletitle] with $id and $title:

$query = "insert into templates (tuid,tname,tdescription,template,archivedefault) values (1,'Sample Archive Template','A sample archive template that only shows the name of the article with a link to the default article viewer.','<a href=\'viewarticle1.php?id=". $id . "\'>".$title."</a>',FALSE)";

Edited by andybebad (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.