PHP and MySQL error

Its really annouying and i can't see the problem!

Page 1 of 1

6 Replies - 1189 Views - Last Post: 16 September 2009 - 11:27 AM Rate Topic: -----

#1 Jono20201   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

PHP and MySQL error

Posted 16 September 2009 - 09:35 AM

Hey,

I've got a annouying error and i can't see the problem..

$query = "INSERT INTO quote(title,name) VALUES ('".$title."','".$name."')";



Error:

Quote

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 'quote(title,name) VALUES ('Mr','Jonathan Martin')' at line 1


Thanks,
Jonathan

Is This A Good Question/Topic? 0
  • +

Replies To: PHP and MySQL error

#2 RudiVisser   User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,566
  • Joined: 05-June 09

Re: PHP and MySQL error

Posted 16 September 2009 - 09:45 AM

$query = "INSERT INTO `quote` (`title`,`name`) VALUES ('" . $title . "', '" . $name . "');";


You need a space after the table name.
Was This Post Helpful? 1
  • +
  • -

#3 Jono20201   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

Re: PHP and MySQL error

Posted 16 September 2009 - 09:51 AM

View PostMageUK, on 16 Sep, 2009 - 08:45 AM, said:

$query = "INSERT INTO `quote` (`title`,`name`) VALUES ('" . $title . "', '" . $name . "');";


You need a space after the table name.


:o Of all my PHP and MySQL coding time i've never EVER had to use that, and i try it and it works!

Can you explain why please?

edit: woops, i didn't read, i ment how you leave a space between the '.'

This post has been edited by Jono20201: 16 September 2009 - 09:53 AM

Was This Post Helpful? 0
  • +
  • -

#4 RudiVisser   User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,566
  • Joined: 05-June 09

Re: PHP and MySQL error

Posted 16 September 2009 - 09:55 AM

You don't need a space after the . that's just my preference, like using the backticks in queries :D
Was This Post Helpful? 0
  • +
  • -

#5 Jono20201   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

Re: PHP and MySQL error

Posted 16 September 2009 - 09:56 AM

View PostMageUK, on 16 Sep, 2009 - 08:55 AM, said:

You don't need a space after the . that's just my preference, like using the backticks in queries :D


I would use them but can't seem to see them on my keyboard.. any help?
Was This Post Helpful? 0
  • +
  • -

#6 RudiVisser   User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,566
  • Joined: 05-June 09

Re: PHP and MySQL error

Posted 16 September 2009 - 10:11 AM

If it's a British keyboard it's the key at the left of 1 :)

`1234567890
!"$%^&*()
Was This Post Helpful? 0
  • +
  • -

#7 Jono20201   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

Re: PHP and MySQL error

Posted 16 September 2009 - 11:27 AM

View PostMageUK, on 16 Sep, 2009 - 09:11 AM, said:

If it's a British keyboard it's the key at the left of 1 :)

`1234567890
!"$%^&*()



haha, i'd never noticed it was there!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1