insert a URL? what is wrong with my insertion?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
wvoyance
Forum Contributor
Posts: 135
Joined: Tue Apr 17, 2012 8:24 pm

insert a URL? what is wrong with my insertion?

Post by wvoyance »

I tried to insert a record into mySQL. I know the following error message must came from the URL insertion
------------------------------------
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/public_html/catalog/admin/includes/functions/database.php on line 45

INSERT INTO products_description(products_id, language_id, products_name, products_description, products_url, extra_value2, extra_value3) VALUES ('452','1','Ji suan ji gai lun','form:BA
language:chi

[TEP STOP]
-------------------------------------

Therefore, I used urlencode and mysql_real_escape_string
$url=mysql_real_escape_string(urlencode(str_replace('http://','',$book['url'][0])));
The URL string after modification by var_dump is
string(51) "www.worldcat.org%2Foclc%2F276913176%3Freferer%3Dxid"

but still got te above error message.

The full insertion command is
================================
tep_db_query("INSERT INTO " . TABLE_PRODUCTS_DESCRIPTION .
"(products_id, language_id, products_name,
products_description, products_url,
extra_value2, extra_value3)
VALUES ('". $products_id . "','" . $language_id . "','" . $book['title'] .
"','form:" . $book['form'][0] . '<br> language:' . $book['lang'] , "'<br>,'" . $url . "','" .
$book['author'] . "','" . $book['year'] . "')
");
================================
The tep_db_query is OSC function. But it simply generate a SQL command.

So, how should I modify it?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: insert a URL? what is wrong with my insertion?

Post by requinix »

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/public_html/catalog/admin/includes/functions/database.php on line 45
It's complaining about what you provided for the $link_identifier parameter, not the query.
Post Reply