Page 1 of 1

jos_content asset_id question...

Posted: Wed Oct 05, 2011 11:59 pm
by btothertotheent
I am giving another site access to post into my jos_content table directly (no risk of bad intentions) but when filling out the rows, what should they put into the:

asset_id
FK to the jos_assets table.

It looks like a unique id number assigned between two tables.... does mysql automatically put the correct number here? or what should I be having assigned here?

Thanks!

Re: jos_content asset_id question...

Posted: Fri Oct 07, 2011 11:35 am
by btothertotheent
Also, any reason why this script is not writing to the database?

Code: Select all

<?php
$dbhost1 = "xx.xx.x.xxx:3306";
$dbuser1 = "xxxxxxxx_xxx";
$dbpassword1 = "xxxxxxxxxx";
$db1 = "xxxxxxxx_xxx";
$connection1 = mysql_connect($dbhost1,$dbuser1,$dbpassword1) or die (mysql_error());

mysql_select_db($db1,$connection1);

mysql_query("INSERT INTO jos_content (title, alias, introtext, fulltext, state, catid)
VALUES ('inserted', 'inserted', 'introtext here', 'fulltext goes here', '1', '77')");
?>
It receives no errors and runs fine... at first it had database connection issues but then I got it fixed. No new rows added though.

Re: jos_content asset_id question...

Posted: Fri Oct 07, 2011 1:27 pm
by radiant_tech
No answers for you on your first question -- I think the asset table is going to give you problems given what you're trying to do. Best to look closely at com_content and see what Joomla is doing with that table when a new article is created.

As to your query, MySQL is probably choking on the "fulltext" field name ... it needs to be surrounded by back quotes (`), the character beneath the tilde.

Can I suggest, however, that you use the built-in database API rather than leaving your db connection info open in your script?

Code: Select all

$db = JFactory::getDbo();
$query = $db->setQuery(true);
$query = "INSERT INTO jos_content (title, alias, introtext, `fulltext`, state, catid)
VALUES ('inserted', 'inserted', 'introtext here', 'fulltext goes here', '1', '77')";
$db->setQuery($query);
$db->query();

Re: jos_content asset_id question...

Posted: Fri Oct 07, 2011 3:39 pm
by btothertotheent
Ok, so the `fulltext` was what was throwing it off. Thank you!

Now it inserted it correctly. I also added a 1 to featured however it didn't show up on the front page... but I think it may be to not adding in the dates etc....

I dont think I can use the API like that because the script is writing to an external server so the ip and database info needs to be present on the server the script is running on.

Re: jos_content asset_id question...

Posted: Sat Jul 30, 2016 8:33 pm
by compusolver
Fields 'state' and 'catid' take integers. Remove the single quotes you've placed around them.
mysql_query("INSERT INTO jos_content (title, alias, introtext, fulltext, state, catid)
VALUES ('inserted', 'inserted', 'introtext here', 'fulltext goes here', 1, 77)");