• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1536
  • Last Modified:

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.
0
bschwarting
Asked:
bschwarting
  • 4
  • 4
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what about this:
if (  ((mysql_num_rows($result) > 0) && ($date1 != '' ) ) {

Open in new window

0
 
bschwartingAuthor Commented:
angelIII, that didn't work either.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you clarify "does not work"
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
bschwartingAuthor Commented:
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";
 }

Open in new window

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
remove "then" , that is not PHP code.
0
 
bschwartingAuthor Commented:
yeah, i tried both ways, still doesn't work.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
let's see this code below.

now, can you get the error logging to see what the actual error is?
http://lu.php.net/errorfunc
if (  (mysql_num_rows($result) > 0) && ($date1 != '' ) ) {

Open in new window

0
 
l0ve2hat3Commented:
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";
 }
0
 
l0ve2hat3Commented:
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";
 }
0
 
bschwartingAuthor Commented:
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 (
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now