Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

what is wrong with my insertion?


xvoyance

Recommended Posts

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 the 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'] . "')

");

================================

 

So, how should I modify it?

Link to comment
Share on other sites

You are misreading the error. It is not complaining about the query it is stating that there is no valid MySQL connection resource.

 

I would hazard a guess that you are running this query externally from osCommerce and without the inclusion of the bootstrapper ( includes/application_top.php )

Link to comment
Share on other sites

You are misreading the error. It is not complaining about the query it is stating that there is no valid MySQL connection resource.

 

I would hazard a guess that you are running this query externally from osCommerce and without the inclusion of the bootstrapper ( includes/application_top.php )

 

I indeed wrote a separate program to do the job. However, I indeed has included that line.

Anyway, the problem has been solve. It is indeed not that string problem.

 

It is that ....''''""""...""..'..'''... mixed up.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...