Jump to content

Insert statement


Bopo

Recommended Posts

Hi

 

Well basically I think there's something wrong with the following code, even if a row is returned, I am still getting a new record with no data appearing in my mysql database, wondering if anyone can see anything:

 

<?php

$date = date('Y/m/d');
date('F, Y',strtotime($date));
include("admin/blogconnect.php");


$breakdate = explode(" ", date('F, Y',strtotime($date)));
$removecomma = substr($breakdate[0], 0, -1);

$sql = "SELECT * FROM months where month = '$storemonth' AND year = '$storeyear'";

$query = mysql_query($sql, $connect);
if(mysql_num_rows($query)== 0) {

$sql1 = "INSERT INTO months (month, year) VALUES ('$storemonth', '$storeyear')";
if(!mysql_query($sql1, $connect)) {
	die('Error' . mysql_error());	


}
} else {
exit ();
}

mysql_close($connect);



?>

Link to comment
https://forums.phpfreaks.com/topic/157022-insert-statement/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.