jos_content asset_id question...

For Joomla! 2.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Note: All 1.6, 1.7 and 3.5 releases have reached end of life and should be updated to 3.x.

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
User avatar
btothertotheent
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 140
Joined: Fri Aug 20, 2010 6:57 pm

jos_content asset_id question...

Post by btothertotheent » Wed Oct 05, 2011 11:59 pm

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!

User avatar
btothertotheent
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 140
Joined: Fri Aug 20, 2010 6:57 pm

Re: jos_content asset_id question...

Post by btothertotheent » Fri Oct 07, 2011 11:35 am

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.

User avatar
radiant_tech
Joomla! Guru
Joomla! Guru
Posts: 531
Joined: Sat Dec 15, 2007 3:02 pm
Location: Washington DC Metro

Re: jos_content asset_id question...

Post by radiant_tech » Fri Oct 07, 2011 1:27 pm

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();

User avatar
btothertotheent
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 140
Joined: Fri Aug 20, 2010 6:57 pm

Re: jos_content asset_id question...

Post by btothertotheent » Fri Oct 07, 2011 3:39 pm

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.

User avatar
compusolver
Joomla! Guru
Joomla! Guru
Posts: 941
Joined: Mon Jan 07, 2008 4:46 am
Location: Florida
Contact:

Re: jos_content asset_id question...

Post by compusolver » Sat Jul 30, 2016 8:33 pm

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)");
- Hank Castello
https://CompuSolver.com
PHP / Joomla / Wordpress / Yii / SEO / Security


Locked

Return to “Joomla! 2.5 Coding”