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.
LVL 1
bschwartingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.