You are here:  » Myssql in logs

Support Forum



Myssql in logs

Submitted by lunen on Mon, 2012-02-20 03:58 in

Hi David,

I'm having trouble using the automation tool and running a full cron job. when I looked at the php log file on my server, I'm getting this error over and over:

[19-Feb-2012 21:51:37] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /myserver/web/content/a/includes/database.php on line 27
[19-Feb-2012 21:51:37] PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /myserver/web/content/a/includes/database.php on line 32
[19-Feb-2012 21:51:37] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /myserver/web/content/a/includes/database.php on line 27
[19-Feb-2012 21:51:37] PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /myserver/web/content/a/includes/database.php on line 32
[19-Feb-2012 21:51:37] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /myserver/web/content/a/includes/database.php on line 27
[19-Feb-2012 21:51:37]

Any ideas?

Submitted by support on Mon, 2012-02-20 08:20

Hi lunen,

Does anything happen at all when cron.php is scheduled to run?

The first thing I would suggest is to enable database debug mode and then trying to run it from within your web browser.

First, edit config.advanced.php and enabled database debug mode at line 6 as follows;

  $config_databaseDebugMode = TRUE;

Then browse to:

/scripts/cron.php

...or if you have an admin password configured in config.advanced.php then:

/scripts/cron.php?password=yourpassword

Extended MySQL error information should then be displayed. If you're not sure from the error where the problem lies if you could post the first few lines of output (assume that it repeats as in your log) I'll check it out.

If it works however (assuming no web based timeout affects complete operation - bear in mind cron.php is not really designed for HTTP invocation) then in would indicate perhaps that when running as CRON job via /usr/local/bin/php that the command line version of PHP on your server is unable to connect to MySQL properly. To test this, I would create a minimal test script as follows:

<?php
  
require("../includes/common.php");
  
$link mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);
  
mysql_select_db($config_databaseName,$link);
  
$result mysql_query("SELECT COUNT(*) FROM `".$config_databaseTablePrefix."products`",$link);
?>

Save the above as crontest.php in the scripts/ folder of your Price Tapestry installation, and then schedule a cron job exactly as per cron.php but simply replace cron.php with crontest.php.

A few minutes after the test was scheduled, check your error log to see if a similar error is displayed; in which case I would contact your host with a copy of the command being scheduled via CRON, and explain that PHP scripts being run via cron don't seem able to access MySQL and they should be able to resolve that in the PHP command line installation...

Cheers,
David.
--
PriceTapestry.com

Submitted by lunen on Mon, 2012-02-20 14:49

Hi david,

I adjusted the included/admin.php file according to these posts. when I went back to the old file the error went away but then I get this error:

[20-Feb-2012 08:33:21] PHP Warning: htmlentities() [<a href='function.htmlentities'>function.htmlentities</a>]: Invalid multibyte sequence in argument in /myserver/web/content/a/html/sidebar.php on line 90

So two things:

1) I think my includes/admin.php is wrong from the adjustments I made to get the % off and adding new items. Should I email that file to you?
2) to solve the above error, here's the code

 print "<option value='".htmlentities($row["brand"],ENT_QUOTES,$config_charset)."' ".$selected.">".$row["brand"]."</option>";

I either have a bad value in the brand or somethings up with the $config_charset right?

Let me know,

Submitted by support on Mon, 2012-02-20 16:37

Hello lunen,

I just noticed an error in the dbmod.php script required as part of the keeping track of new products modification (this thread) which would mean that the database fields required for that modification weren't in place - I have corrected that now in this post so that should be all it is...

Regarding the invalid multi-byte sequence - this is most likely a single value encoding error; otherwise you would likely be seeing invalid characters displayed throughout your site. To avoid further warnings being generated the first option would be to suppress warnings from that particular call to htmlentities by replacing with:

 print "<option value='".@htmlentities($row["brand"],ENT_QUOTES,$config_charset)."' ".$selected.">".$row["brand"]."</option>

Alternatively, add a Global Filter to the Brand field; and use either UTF8 Encode (if your site is utf-8) or UTF8 Decode (if your site is iso-8859-1) and that will ensure that all data imported is valid for that character encoding.

Hope this helps!
Cheers,
David.

--
PriceTapestry.com

Submitted by lunen on Mon, 2012-02-20 16:57

thanks david, the code above fixed that error.

I ended up manually adding the fields to my database, so they are in there for deleteme and timestamp. I noticed that some code was different on my admin.php versus the example mainly instead of looking at the merchant field my code is filename.

anyhow, in the meantime I switched the code back to the original admin.php and i'm still getting the php errors from the database.php file, when just pulling up a webpage. I have the debugging on. what should I be looking for?

Submitted by support on Mon, 2012-02-20 17:12

Hi lunen,

If you'd like to email me your includes/admin.php i'll make the updated products modification relevant to your version for you.

Whenever a MySQL error is reported in the error log; if database debug mode is enable the extended error message should be output however it may not necessarily be rendered by the browser depending upon where about in the HTML stream it occurs.

To view the error, use your browser's View > Source feature to view the raw HTML and search for the character sequence:

][

(close square-bracket, open square-bracket)

If you're not sure from the MySQL error message displayed where the problem lies let me know what is displayed and I'll check it out...

Cheer,
David.
--
PriceTapestry.com