SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Quick php/mysql question.
-
Jun 4, 2007, 09:28 #1
- Join Date
- Jun 2004
- Location
- UK
- Posts
- 148
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Quick php/mysql question.
hi, im trying to enter some values into my database vis my script im using this peice of code.
Code:$sqlrun = "INSERT INTO 'netboomy_links.linkinfo' ('url' ,'decr' ) VALUES ('$_POST[url]', '$_POST[discription]') "; echo "Sql Query"; echo $sqlrun; if(!mysql_db_query("netboomy_links",$sqlrun,$dbh)) die(mysql_error());
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 ''netboomy_links.linkinfo' ('url' ,'decr' ) VALUES ('http://www.PleaseWork.com', ' at line 1
I've had a play around with it but cant seem to see what is wrong with it. any help would be great.
-
Jun 4, 2007, 09:42 #2
- Join Date
- May 2005
- Location
- London, ON
- Posts
- 360
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try removing the quotes in the first part:
PHP Code:$url = mysql_real_escape_string($_POST['url']);
$desc = mysql_real_escape_string($_POST['description']);
$sqlrun = "INSERT INTO netboomy_links.linkinfo (url ,decr ) VALUES ('".$url."', '".$desc."') ";
-
Jun 4, 2007, 10:20 #3
- Join Date
- Jun 2004
- Location
- UK
- Posts
- 148
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks Jean, the code you gave worked first time.. I just want to know whats the differance between these 2 lines
$sqlrun = "INSERT INTO 'netboomy_links.linkinfo' (url ,decr) VALUES ('$_POST[url]', '$_POST[discription]') ";
//$sqlrun = "INSERT INTO netboomy_links.linkinfo (url ,decr ) VALUES ('".$url."', '".$discription."') ";
I took out the quotes on the first part like you suggested. im guessing you cant then use the $_POST global variables to do this? just want to get it clear in my head why it isnt working?
cheers
darren.
-
Jun 4, 2007, 10:42 #4
- Join Date
- Jan 2004
- Location
- Dubai
- Posts
- 259
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:'netboomy_links.linkinfo'
I adore PHP
-
Jun 4, 2007, 11:12 #5
- Join Date
- May 2005
- Location
- London, ON
- Posts
- 360
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Jun 5, 2007, 07:28 #6
- Join Date
- Mar 2005
- Location
- Ukraine
- Posts
- 1,403
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Bookmarks