Haji
Oct 05, 2007, 03:05 AM
can someone tell me if this code is right?
<?php
include("config.php");
?>
<?
mysql_query("update players set energy=max_energy");
mysql_query("update players set hp=max_hp");
mysql_query("update outposts set turns=5");
mysql_query("update outposts set tokens=tokens+100");
mysql_query("update players set ap=ap+3");
mysql_query("update players set age=age+1");
?>
or should it be
<?php
include("config.php");
mysql_query("update players set energy=max_energy");
mysql_query("update players set hp=max_hp");
mysql_query("update outposts set turns=5");
mysql_query("update outposts set tokens=tokens+100");
mysql_query("update players set ap=ap+3");
mysql_query("update players set age=age+1");
?>
maximus242
Oct 05, 2007, 10:26 AM
Well the easiest way to tell is just to test them both and see which one works.
lucid_dream
Oct 05, 2007, 12:24 PM
both codes do the exact same thing. It doesn't matter if you break it up using <? and ?>. However, your code will not work as is. For starters, you need mysql_connect and to use quotes around strings in your mysql queries.
maximus242
Oct 06, 2007, 12:03 AM
Ah yea thats right. Its been a very long time since ive programmed in php.
He has a config file included they're so I wonder if he just put the mysql connect in the config file. Usually you have your config file and your file to open the db connection.
If you havent opened your connection to the database in your code yet, its relatively simple to do.
Heres some example code
<?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
?>
Just save that as a php file, like I dono, openconnect or dbconn then include it when you want to open your connection to the database
Haji
Oct 06, 2007, 12:44 AM
ok the script works but only when I manually open the page myself.
when I try and use a cron job i get this error.
/home/rseclan/public_html/linkway/reset.php: line 1: ?php: No such file or directory
/home/rseclan/public_html/linkway/reset.php: line 2: syntax error near unexpected token `"config.php"'/home/rseclan/public_html/linkway/reset.php: line 2: `include("config.php");'
I put /home/rseclan/public_html/linkway/reset.php in because thats the path the file manger gives me.
also I have asked the host themsevles and they said thats the correct path.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.