Author Topic: oen sql command  (Read 357 times)

0 Members and 1 Guest are viewing this topic.

Offline runeverydayTopic starter

  • Enthusiast
  • Posts: 117
    • View Profile
oen sql command
« on: March 17, 2010, 09:25:45 PM »
$sql 'INSERT INTO joke SET joketext="' $joketext '", jokedate="today's date"';  
i don't understand the line
Code: [Select]
joketext="' . $joketext . '", why it use the single quote and the concatenation . i feel those are a surplus, use this is joketext="$joketext ", ok, but when i test it ,it's show an error, anyone can tell me the reason.any tips would be appreciated.

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: oen sql command
« Reply #1 on: March 17, 2010, 10:58:34 PM »
Your getting an error because of the ' in today's

Offline Kryptix

  • Enthusiast
  • Posts: 269
  • Gender: Male
    • View Profile
    • RuneScape Classic
Re: oen sql command
« Reply #2 on: March 18, 2010, 12:00:22 AM »
Use this:

$sql "INSERT INTO `joke` SET `joketext` = '" $joketext "', `jokedate` = 'today\'s date';";  
« Last Edit: March 18, 2010, 12:00:59 AM by Kryptix »

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: oen sql command
« Reply #3 on: March 22, 2010, 04:27:45 PM »
Or actually escape your input data properly.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.