bschwarting
asked on
mysql syntax - if then and
why isn't this working?
if ((mysql_num_rows($result) > 0) and $date1 != '' then {
i need to check two things, if the $result is great than zero and make sure $date isn't blank.
if ((mysql_num_rows($result) > 0) and $date1 != '' then {
i need to check two things, if the $result is great than zero and make sure $date isn't blank.
ASKER
angelIII, that didn't work either.
can you clarify "does not work"
ASKER
the page is blank, if i remove this code, it works fine
if ( ((mysql_num_rows($result) > 0) && ($date1 != '' ) ) then {
$sql2 = "INSERT INTO $createtablename (date2, timesubmit2, answer2) VALUES ( ' $date1 ' , ' $timesubmitcombine ' , ' $answer ' ) ;";
mysql_query($sql2) or die ("Error in query: $sql2. ".mysql_error());
echo "Updated";
}
else {
echo "NOT READY TO INSERT";
}
remove "then" , that is not PHP code.
ASKER
yeah, i tried both ways, still doesn't work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try this
if ((mysql_num_rows($result) > 0) && ($date1 != '' ) ) {
$sql2 = "INSERT INTO $createtablename (date2, timesubmit2, answer2) VALUES ( ' $date1 ' , ' $timesubmitcombine ' , ' $answer ' ) ;";
mysql_query($sql2) or die ("Error in query: $sql2. ".mysql_error());
echo "Updated";
}
else {
echo "NOT READY TO INSERT";
}
if ((mysql_num_rows($result) > 0) && ($date1 != '' ) ) {
$sql2 = "INSERT INTO $createtablename (date2, timesubmit2, answer2) VALUES ( ' $date1 ' , ' $timesubmitcombine ' , ' $answer ' ) ;";
mysql_query($sql2) or die ("Error in query: $sql2. ".mysql_error());
echo "Updated";
}
else {
echo "NOT READY TO INSERT";
}
sorry try this
if ((mysql_num_rows($result) > 0) && ($date1 != '') ) {
$sql2 = "INSERT INTO $createtablename (date2, timesubmit2, answer2) VALUES ( ' $date1 ' , ' $timesubmitcombine ' , ' $answer ' ) ";
mysql_query($sql2) or die ("Error in query: $sql2. ".mysql_error());
echo "Updated";
}
else {
echo "NOT READY TO INSERT";
}
if ((mysql_num_rows($result) > 0) && ($date1 != '') ) {
$sql2 = "INSERT INTO $createtablename (date2, timesubmit2, answer2) VALUES ( ' $date1 ' , ' $timesubmitcombine ' , ' $answer ' ) ";
mysql_query($sql2) or die ("Error in query: $sql2. ".mysql_error());
echo "Updated";
}
else {
echo "NOT READY TO INSERT";
}
ASKER
sorry all, i thought i closed this.
angelIII last response fixed it. i think we had a double (( before mysql_num_rows and only needed a single (
angelIII last response fixed it. i think we had a double (( before mysql_num_rows and only needed a single (
Open in new window