Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i insert info to a table?

Status
Not open for further replies.

verbatim1

Programmer
Apr 18, 2005
58
US
when trying to insert to a table info for a picture with a html link to another site on it i get an error message:

counter INSERT error: 1064, You have an error in your SQL syntax near 'href="" target="_blank"><img src="/uploa' at line 1


the mysql code is below

Code:
$damn = '"<a href="[URL unfurl="true"]www.mysite.com"[/URL] target="_blnk"><img src="/uploads/mho.jpg" alt="We're here" /></a>"';
 $c_insert = "INSERT INTO `timmy_config` VALUES ('pic4', $damn, 0)" or die('counter INSERT error: '.mysql_errno().', '.mysql_error());;

can someone tell me how i can get the image source and link sent to my table please?

Thanks in advance
 
Thats actually PHP you're having problems with: escaping the double-quotes: ""

Also, your insert statement doesn't insert - you need to use mysql_query() function.

Do this:
Code:
$damn = "<a href='[URL unfurl="true"]http://www.mysite.com'[/URL] target='_blank'><img src='/uploads/mho.jpg' alt='We're here' /></a>";
$sql = "INSERT INTO `timmy_config` VALUES ('pic4', '$damn', 0)";
$result = mysql_query($sql,$connection) 
  or die('counter INSERT error: '.mysql_errno().', '.mysql_error());

I suggest you do a bit of reading up on PHP/MySQL websites - to help you with your syntax.

[cheers]
Cheers!
Laura
 
thanks!!

now i get the error:

counter INSERT error: 1064, You have an error in your SQL syntax near '<img src='/uploads' at line 1

why is that?
 
You have to double-escape the '/ ...

so <img src='/uploads' should be <img src='//uploads' ...

Try and help yourself out before running straight to the forums.

[cheers]
Cheers!
Laura
 
Thanks again LTeeple,

now i get the error:

counter INSERT error: 1064, You have an error in your SQL syntax near '<img src='//upload' at line 1
 
And escape the quote (') instead of the slash.

... values('<img src=\'/upload\'',....)
 
Any time you run into a problem like this, print out the text of the SQL query before running it. Then you will see exactly what is being passed to the server, and the syntax error will probably be obvious.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top