473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Return value of 1 instead of -1

How can i get a return value of 1 if the user exists in the table instead of it returning a -1?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require("config.php");
  3. if($_GET['action'] == 'post')
  4. {
  5.    if(empty($_POST['Employee_ID']) || empty($_POST['Date']) || empty($_POST['Activity']) || empty($_POST['Miles']))
  6.     {
  7.       //if everything is not filled in than prints out error message
  8.       error("blank");
  9.       exit;
  10.       }
  11.       if(!empty($_POST['Employee_ID']))
  12.       {
  13.        $query="SELECT Employee_ID FROM analyzer_query WHERE Employee_ID = '{$_POST['Employee_ID']}'";
  14.        $rs = $conn->execute($query);
  15.        $num_columns = $rs->RecordCount();
  16.        echo $num_columns . "<br>";
  17.                     if($num_columns <= 0)
  18.                         {
  19.                           echo error ("user");
  20.                           exit;
  21.                         }
  22.                         else
  23.                         {
  24.                         $conn->execute("INSERT INTO Activity_Log (`Employee_ID`, `Date`, `Activity`, `Miles`) VALUES ('{$_POST['Employee_ID']}', '{$_POST['Date']}', '{$_POST['Activity']}', '{$_POST['Miles']}')");
  25.                         header("Location: success.php?action=success");
  26.                         }
  27.  }
  28. }
  29. function error($error)
  30. {
  31.    //if error is equal to blank
  32.    if($error == 'blank')
  33.       {
  34.       echo "Please fill in all the required fields before submitting";
  35.       }
  36.  //if error is equal to blank
  37.    if($error == 'user')
  38.       {
  39.       echo "Please fill in the correct Employee ID";
  40.       }
  41. }
  42. ?>
here is my config.php file
Expand|Select|Wrap|Line Numbers
  1. <?php  $conn = new COM ("ADODB.Connection") or die("Cannot start ADO");
  2. $connStr = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=F:\Wellness Program\Copy of HR Employee Wellness Program.mdb;";
  3. $conn->open($connStr); //Open the connection to the database
  4. ?>
  5.  
Nov 7 '07 #1
2 1147
Atli
5,058 Expert 4TB
Hi. Welcome to TSDN!

I assume this has something to do with the $rs->RecordCount() method?
Please explain a little better what you are talking about.

You could of course always simply change the value:
Expand|Select|Wrap|Line Numbers
  1. if($value == -1) $value = 1;
  2.  
Nov 10 '07 #2
Or you can get the absolute value:

[PHP]$value = abs($value);[/PHP]
Nov 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Konstantin Zakharenko | last post by:
Hello, Our QA team have running a lot of test scripts (for automated regression testing), they run them on the different databases (Oracle/MS SQL). Several of those tests are dependent on the...
27
by: Maximus | last post by:
Hi, I was just wondering, is it good to use return without arguments in a void function as following: void SetMapLayer() { if( !Map ) return; layer = LAYER_MAP; }
5
by: Neal Coombes | last post by:
Posted to comp.lang.c++.moderated with little response. Hoping for better from the unmoderated groups: -------- Original Message -------- Subject: Return appropriately by value, (smart)...
6
by: Bruce W.1 | last post by:
The intent of my web service is an RSS feed from a blog. Originally I used a StringBuilder to make the XML and returned a string from the webmethod. But this doesn't display properly in IE. So...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
5
by: Dmitriy Lapshin [C# / .NET MVP] | last post by:
Hi all, I think the VB .NET compiler should at least issue a warning when a function does not return value. C# and C++ compilers treat this situation as an error and I believe this is the right...
8
by: WakeBdr | last post by:
I'm writing a class that will query a database for some data and return the result to the caller. I need to be able to return the result of the query in several different ways: list, xml,...
4
by: Zytan | last post by:
It seems I cannot return a reference to a value type as the return value of a method. I will have to use an out parameter instead. Is there another way to do it? Zytan
1
by: Sudarhan | last post by:
Hello frnds I have created a webbased form using asp and javascript .. while submitting the form i am validating the fields in the form .it validates the field and returns alert message. but when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.