Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP File for database changes


tomb321

Recommended Posts

I know how to setup a CRON job and I know how to do an SQL query to make database changes .My problem is the development of the php file that the CRON job runs so I don't have to do the SQL query manually. (If there is an easier way to get this done, please let me know.)

 

I'm trying to get the product status changed to inactive when the quantity is 0.

 

What I have so far is:

 

<$php
require('includes/functions/database.php');
tep_db_connect() or die('Unable to connect to database server!');
$sql = "UPDATE products SET products_status = 0 WHERE products_quantity = 0";
$result = mysql_query($sql);
tep_db_close();
?>

 

But it's not working (I'm not a coder). Any help with this would be appreciated.

Link to comment
Share on other sites

It should work. This is what the code should look like

 require('includes/application_top.php');
 tep_db_query("UPDATE products SET products_status = 0 WHERE products_quantity = 0");

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

I'm getting the following error:

 

<br />

<b>Warning</b>: require(includes/application_top.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in <b>/home/xxxxxxx/public_html/xxxxxx/includes/test.php</b> on line <b>3</b><br />

<br />

<b>Warning</b>: require(includes/application_top.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in <b>/home/xxxxxxx/public_html/xxxxxx/includes/test.php</b> on line <b>3</b><br />

<br />

<b>Fatal error</b>: require() [<a href='function.require'>function.require</a>]: Failed opening required 'includes/application_top.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in <b>/home/xxxxxxx/public_html/xxxxxxx/includes/test.php</b> on line <b>3</b><br />

 

 

Line 3 is

 

require('includes/application_top.php');

 

application_top.php is there

 

Full code

 

<?php

require('includes/application_top.php');
tep_db_query("UPDATE products SET products_status = 0 WHERE products_quantity = 0");

?>

Link to comment
Share on other sites

You were already in the "includes" directory (folder), so trying to find "includes/application_top.php" isn't going to work. You would either have to require just "application_top.php", or as Dan suggested, move your script up one level so that "includes/application_top.php" can be found.

 

Frankly, if you're having that much trouble with such basic PHP, I fear for your ability to do the rest of it. At the very least, back up your files and database (and make sure they're good backups) before running this thing on a live database.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...