Thread subject: pHpFusion Nederlands (BE|NL) » Ondersteuning, Themas, Infusies, Modificaties en Installatie :: Autonews Infusion

Posted by afoster on 20 februari 2019, 22:50
#1

Trying to adapt the autonews infusion to php-fusion 8.00.xx and after some trial and error was able to infuse it. I still can't get it to send out emails but at the moment, I am getting the following error message in the error log.

Error
autonews/autonews_include.php
mysql_result() expects parameter 1 to be resource, object given Line: 393

line: 393 shows

Code

$rtn = mysql_result($result, 0);


Can anyone tell me how to fix it?

Posted by douwe_yntema on 24 februari 2019, 16:26
#2

mysql_result is deprecated in php5.6 and removed in php 7.0, so it is not recommend to use this function


You should use the function dbcount from maincore

It should be something like:

$rtn = dbcount("somefield", DB_USERS, "autonews='1'")

Code

**
 * Count the number of rows in a table filtered by conditions
 *
 * @global int   $mysql_queries_count
 * @global array $mysql_queries_time
 *
 * @param string $field      Parenthesized field name
 * @param string $table      Table name
 * @param string $conditions conditions after "where"
 *
 * @return boolean
 */
function dbcount($field, $table, $conditions = "") {
    $cond = ($conditions ? " WHERE ".$conditions : "");
    $sql = "SELECT COUNT".$field." FROM ".$table.$cond;
    try {
        $statement = dbconnection()->prepare($sql);
        $statement->execute();
        return $statement->fetchColumn();
    } catch (PDOException $e) {
        trigger_error($e->getMessage(), E_USER_ERROR);
        echo $e;
        return FALSE;
    }
}

Edited by douwe_yntema on 24 februari 2019, 16:31

Posted by afoster on 24 februari 2019, 17:16
#3

Quote

douwe_yntema schreef:

mysql_result is deprecated in php5.6 and removed in php 7.0, so it is not recommend to use this function


You should use the function dbcount from maincore

It should be something like:

$rtn = dbcount("somefield", DB_USERS, "autonews='1'")

Code

**
 * Count the number of rows in a table filtered by conditions
 *
 * @global int   $mysql_queries_count
 * @global array $mysql_queries_time
 *
 * @param string $field      Parenthesized field name
 * @param string $table      Table name
 * @param string $conditions conditions after "where"
 *
 * @return boolean
 */
function dbcount($field, $table, $conditions = "") {
    $cond = ($conditions ? " WHERE ".$conditions : "");
    $sql = "SELECT COUNT".$field." FROM ".$table.$cond;
    try {
        $statement = dbconnection()->prepare($sql);
        $statement->execute();
        return $statement->fetchColumn();
    } catch (PDOException $e) {
        trigger_error($e->getMessage(), E_USER_ERROR);
        echo $e;
        return FALSE;
    }
}


Thank you so much for your help.

Posted by douwe_yntema on 24 februari 2019, 21:01
#4

You are welcome.

Please let me know if you get the infusion working. I am interested in it.

Posted by afoster on 25 februari 2019, 16:21
#5

Quote

douwe_yntema schreef:

You are welcome.

Please let me know if you get the infusion working. I am interested in it.


No I still can't send any emails and making the change you suggested gave me all kinds of error messages that I do not know how to fix. I am attaching the infusion to this message in the hope you can figure out how get it working. I have it working on php-fusion 7.02.07 but it will not send emails on php-fusion 8.00.21

Posted by douwe_yntema on 25 februari 2019, 19:22
#6

Without looking in the code my first guess the source of the problem lies in the php-version in stead of the php-fusion version.

I will take a look at your attached files. But not whitin this week.

Posted by douwe_yntema on 28 februari 2019, 19:09
#7

On what configuration have you tested the autonews infusion?

I tested it on PHP-Fusion 8.0.20 on PHP 5.6.40 and 5.5.5-10.1.38-MariaDB

It is not running at all.

And next question: On what configuration are you planning to use it?

Just to make sure.

Posted by afoster on 02 maart 2019, 18:53
#8

Quote

douwe_yntema schreef:

On what configuration have you tested the autonews infusion?

I tested it on PHP-Fusion 8.0.20 on PHP 5.6.40 and 5.5.5-10.1.38-MariaDB

It is not running at all.

And next question: On what configuration are you planning to use it?

Just to make sure.


I have been using it on two sites running php-fusion 7.02.07 and am trying to adapt it to a site running php-fusion 8.00.21 using php version 5.6.3. I have been able to get it infused but can't get it to send out any email. I am attaching a zip file that contains all the original files of the infusion and I thank you for your offer to help.

Posted by douwe_yntema on 02 maart 2019, 20:48
#9

I Got your infusion working and sending mail.

In file autonews_include.php line 393 must be changed to:

Code

$rtn = dbrows($result);


Furthermore to send mail, it is file autonews_cronjob.php that says:

// To activate this file, set $locale['AN042'] to TRUE and insert a password below
// Use 'http://wwww.mysite.com/infusion/autonews/autonews_cronjob.php?pw=mypassword' from cronjob

But, $locale['AN042'] does not exist. You need to change in file autonews_param.php, line 30 to:
Code

$autonews_params['cronjob'] = TRUE;    // TRUE if cronjob is used - FALSE otherwise


and enter a password in file autonews_cronjob.php in line 24.

Then call the cronjob as state as:
http://wwww.mysite.com/infusion/autonews/autonews_cronjob.php?pw=mypassword

where the password is from autonews_cronjob.php line 24.

of course you need to set up PHP-Fusion correctly for sending mail.

There are some warnings about shoutbox, I infused the shoutbox, but not set it up. Don't know if this need to be digged out deeper.

Edited by douwe_yntema on 01 januari 1970, 01:00

Posted by afoster on 02 maart 2019, 20:53
#10

Quote

douwe_yntema schreef:

I Got your infusion working and sending mail.

In file autonews_include.php line 393 must be changed to:

Code

$rtn = dbrows($result);


Furthermore to send mail, it is file autonews_cronjob.php that says:

// To activate this file, set $locale['AN042'] to TRUE and insert a password below
// Use 'http://wwww.mysite.com/infusion/autonews/autonews_cronjob.php?pw=mypassword' from cronjob

But, $locale['AN042'] does not exist. You need to change in file autonews_param.php, line 30 to:
Code

$autonews_params['cronjob'] = TRUE;    // TRUE if cronjob is used - FALSE otherwise


and enter a password in file autonews_cronjob.php in line 24.

Then call the cronjob as state as:
http://wwww.mysite.com/infusion/autonews/autonews_cronjob.php?pw=mypassword

where the password is from autonews_cronjob.php line 24.

of course you need to set up PHP-Fusion correctly for sending mail.

There are some warnings about shoutbox, I infused the shoutbox, but not set it up. Don't know if this need to be digged out deeper.


Thanks for your response again douwe_yntema. I was never running a cron job on my other sites, but if that is what it takes to make this work with this version of autonews, then I will do so. I will follow your suggestions and get back to you.

Posted by afoster on 02 maart 2019, 20:58
#11

Quote

douwe_yntema schreef:

I Got your infusion working and sending mail.

In file autonews_include.php line 393 must be changed to:

Code

$rtn = dbrows($result);


Furthermore to send mail, it is file autonews_cronjob.php that says:

// To activate this file, set $locale['AN042'] to TRUE and insert a password below
// Use 'http://wwww.mysite.com/infusion/autonews/autonews_cronjob.php?pw=mypassword' from cronjob

But, $locale['AN042'] does not exist. You need to change in file autonews_param.php, line 30 to:
Code

$autonews_params['cronjob'] = TRUE;    // TRUE if cronjob is used - FALSE otherwise


and enter a password in file autonews_cronjob.php in line 24.

Then call the cronjob as state as:
http://wwww.mysite.com/infusion/autonews/autonews_cronjob.php?pw=mypassword

where the password is from autonews_cronjob.php line 24.

of course you need to set up PHP-Fusion correctly for sending mail.

There are some warnings about shoutbox, I infused the shoutbox, but not set it up. Don't know if this need to be digged out deeper.


I forgot to ask if you actually sent the email from the screenshot you posted. I got that far in the infusion as well, but the email was never sent.

Posted by douwe_yntema on 02 maart 2019, 21:08
#12

The screen shot is from my mail program.

I was confused also when clicking the test link, you get an preview of the mail in your browser, but the mail is not sent.
To send the mail, you need to execute the autonews() function, which is actually done from the cronjob.

Or you must make a call to the autonews() function from somewhere else. e.g. from the footer of your site.
Or make a panel whitout content and call it cronjob.
Every time a visitor comes on your site, the code is executed.

Posted by afoster on 02 maart 2019, 21:19
#13

Quote

douwe_yntema schreef:

The screen shot is from my mail program.

I was confused also when clicking the test link, you get an preview of the mail in your browser, but the mail is not sent.
To send the mail, you need to execute the autonews() function, which is actually done from the cronjob.

Or you must make a call to the autonews() function from somewhere else. e.g. from the footer of your site.
Or make a panel whitout content and call it cronjob.
Every time a visitor comes on your site, the code is executed.


Do you mean the autonews() function in autonews_cronjob.php or somewhere else? As you can tell, I am not very well versed in php.

BTW, how can I respond to your posts without having to quote the message? I can't seem to find the link that will let me do that.

Posted by douwe_yntema on 02 maart 2019, 21:28
#14

The function autonews() is located in autonews_include.php:

Code

// Does what has to be done at all times - returns TRUE if something has happened
function autonews()
{
  $autonews_settings = autonews_readdb();
  if ($rtn = autonews_check($autonews_settings))
  {
    autonews_send($autonews_settings);
  }
  return $rtn;
}


This function is calling autonews_check and if there is something to send, autonews_send is called (see below autonews function in te file)

Button explained in attachment :)

Posted by afoster on 02 maart 2019, 21:41
#15

Thanks, I will see if I can get the cronjob to work. I would still like the infusion to work (send emails) without using a cron job...I know it is possible because it is working on two different php-fusion 7.02.07 sites.

Posted by douwe_yntema on 02 maart 2019, 22:02
#16

Oh no I forgot:

For the infusion to infuse, in infusion.php search for Type=MyISAM;
and replace with ENGINE=MyISAM; (twice)

I checked again, but the autonews function is also called from the autonews panel, if the cronjob parameter is set to false. It was in the readme. But then then the mails are only sent if the panel is executed, so if a visitor enters your site.


Sorry not to mention this before.

I just tested and it works also

Posted by afoster on 02 maart 2019, 23:02
#17

I was aware of the Type=MyISAM issue as that is the reason why it did not infuse correctly originally.

When you say "I just tested and it works also", do you mean it is working without using cron job? If so, I would love it if you could zip up your whole infusion (changing db connection details) and add it to a post here. Perhaps when comparing the files I could figure out where the problem lies for me.

Posted by afoster on 03 maart 2019, 04:57
#18

I defused and re-infused the autonews and it now seems to be working without the cronjob. Don't really know what I did but I am happy that it is working.

Again, it is on a site running php-fusion 8.00.21, with php version 5.6.3

Thanks again for your help on this.

Posted by douwe_yntema on 03 maart 2019, 08:57
#19

Quote

afoster schreef:

I was aware of the Type=MyISAM issue as that is the reason why it did not infuse correctly originally.

When you say "I just tested and it works also", do you mean it is working without using cron job? If so, I would love it if you could zip up your whole infusion (changing db connection details) and add it to a post here. Perhaps when comparing the files I could figure out where the problem lies for me.


Yes it is working whitout the cron job if you make the setting in the file autonews_param.php, line 30 to:
Code


$autonews_params['cronjob'] = FALSE;   

Edited by douwe_yntema on 01 januari 1970, 01:00

Posted by douwe_yntema on 03 maart 2019, 09:00
#20

Quote

afoster schreef:

I defused and re-infused the autonews and it now seems to be working without the cronjob. Don't really know what I did but I am happy that it is working.

Again, it is on a site running php-fusion 8.00.21, with php version 5.6.3

Thanks again for your help on this.



Glad it is working. Maybe a setting that was set to default again after infusion