Hello,
I defnitely don't consider myself a coder but have been installing and troubleshooting
pre-made php scripts for a few years now and figure now is a good time to learn as I'm
quite sick of having to rely on outsourced help
I am currently trying to create a simple (hope so) script that will run on a cron every
other minute to insert a specific piece of data each time a new member joins and it
should only insert the data once based on criteria.
Here's what I'm trying to do exactly with a php script
check members table if field signup_date is TODAY's Date and if user_balance field is 0.00 then alter/update user_balance field 25.00
Now, I've hit a bit of a roadblock with getting the MySQL query format correct.
The SIGNUP_DATE field in the database is DATETIME format and the like with wildcard thing isn't
working for me.
Is there anyone who can point me in the right direction with the proper wildcard date format?
It'd be a great help. Anything at all is massively appreciated.
Here's the code I have so far...the echo is in there so I can see if it's working correctly.
I'm pretty sure I haven't got the right function to display the result of the query either but
I think I can figure that out pretty easily.
<?php
$today = date("Y-m-d");
mysql_connect("localhost", "DBUSER", "DBUSER") or die(mysql_error());
mysql_select_db("DBNAME") or die(mysql_error());
$sql1 = mysql_query("SELECT USER_NAME FROM members WHERE SIGNUP_DATE LIKE '$today%");
if($sql1 == false)
{
user_error("Query failed: " . mysql_error() . "<br />\n$query");
}
elseif(mysql_num_rows($sql1) == 0)
{
echo "<p>Sorry, no rows were returned by your query.</p>\n";
}
$memberseligible = mysql_fetch_array($sql1);
echo "$memberseligible";
?>