Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Mysql Query
ghostrider
post Mar 10 2007, 12:11 AM
Post #1


Super Member
*********

Group: Members
Posts: 397
Joined: 9-June 06
From: Wisconsin
Member No.: 24,924



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

CODE
$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)";
Go to the top of the page
 
+Quote Post
saga
post Mar 10 2007, 12:34 AM
Post #2


Premium Member
********

Group: Members
Posts: 165
Joined: 12-September 05
Member No.: 11,777



$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?

This post has been edited by saga: Mar 10 2007, 12:37 AM
Go to the top of the page
 
+Quote Post
andybebad
post Mar 11 2007, 06:45 PM
Post #3


Newbie [Level 1]
*

Group: Members
Posts: 12
Joined: 8-March 07
From: Gtown, Wisconsin
Member No.: 39,728



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).

CODE
$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:
CODE
$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)";


This post has been edited by andybebad: Mar 11 2007, 06:46 PM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Problem On Mysql "order By"(5)
  2. Increment A Mysql Column(6)
  3. Can You Add Images Into A Mysql Database?(20)
  4. Creating Profiles In Php/mysql ?(7)
  5. Php Search Engine Script For Mysql Database(11)
  6. How To Delete A Row In Mysql.(4)
  7. Editing Information In A Mysql Database And Deleting Rows(5)
  8. Putting Data Of 2 Pages In Mysql At Once(1)
  9. Simple Mysql Query Limiting(9)
  10. Some Mysql Basics(4)
  11. Php, Mysql, Apache(4)
  12. Php And Mysql Applications(3)
  13. Getting Php 5 To Work With Mysql(0)
  14. Problem With A Mysql Join(2)
  15. The Artists Tutorials :mysql Basic Commands(0)
  1. [mysql]get Id Of Loged In User?(7)
  2. [mysql/php]need Som Basic Help(13)
  3. [php/mysql]id Trouble [resolved](3)
  4. Mysql Won't Update(4)
  5. Php + Mysql Question!(4)
  6. Tools Needed!(9)
  7. Best Sites For Learning Php-mysql(4)
  8. Sql Query(19)
  9. Php And Mysql Programming(2)
  10. Best Php And Mysql Editor For Noobs(6)
  11. Html Form!(4)
  12. Mysql Error(3)
  13. Create Table - Mysql Code - Help(1)


 



- Lo-Fi Version Time is now: 26th July 2008 - 03:42 PM