Hi everyone!
The code above takes the news from a table and insert the news into Joomlas jos_content
<?php
$user = "****";
$pass = "****";
$host = "localhost";
$database = "nh";
$connection = mysql_connect($host,$user,$pass)
or die(mysql_error());
mysql_select_db($database)
or die(mysql_error());
$query = "SELECT * FROM admin_news ORDER BY nid DESC LIMIT 10";
$result = mysql_query($query)
or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$row['headline'];
$row['nick'];
$row['date'];
$row['preview'];
$row['news'];
$database2 = "joomla";
mysql_select_db($database2,$connection)
or die(mysql_error());
$query2 = "INSERT INTO jos_content(
title,
alias,
title_alias,
introtext,
`fulltext`,
state,
sectionid,
mask,
catid,
Created,
Created_by,
Created_by_alias,
modified,
modified_by,
checked_out,
checked_out_time,
publish_up,
publish_down,
images,
urls,
attribs,
version,
parentid,
ordering,
metakey,
metadesc,
access,
hits,
metadata) VALUES(
'".mysql_real_escape_string($row['headline'])."',
'',
'',
'".mysql_real_escape_string($row['preview'])."',
'".mysql_real_escape_string($row['news'])."',
'',
2,
'',
1,
'',
62,
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'')";
$result2 = mysql_query($query2)
or die(mysql_error());
}
echo "done";
?>
The problem is when I set the sectionid to 2, which is the id for the News Section. But in the administrator, the news doesn't belong to any section, and it is defined as "Uncategorised".
How can I solve this?