kvigor wrote:
Sorry I re-wrote for problem clarity.

FYI whenever I do a var_dump it always shows $stringOne as being 2 characters less

e.g.
var_dump($foodlandPA[45]);
var_dump($storeInfo);

string(31) "Wellston Foodland Wellston OH " string(29) "Wellston Foodland Wellston OH"

This would be because of the ' ' and "\n" at the end of the 31 char line

use trim to remove the white space before your comparison and it should work.

One other thing I noticed, in your SQL insert statement, are all variables coming from the post? If so, do you need to reference the $_POST['..'] array instead and clean them??

or have you already done that?


""kvigor"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
Hello,

I'm using the file function to create an array. I'm also using values from a form to see if it matches any elements in the array.

My problem is I expect the condition to be true, but my DB isn't populated as it should be if condition was true.
=================Code Begins======================================================
$theFileArray = file('C:\htdocs\folder1\file.txt');


if(isset($_POST['strName'], $_POST['strCity'], $_POST['strState']))
{
$space = " ";
$stringOne = $_POST['strName']. $space. $_POST['strCity']. $space . $_POST['strState'];

}
//I match the string "Grantsville Foodland Grantsville MD" letter for letter in the form and form info gets stored in unknown table and not central as it should...?

if(in_array($stringOne, $theFileArray)) //Any Problem solvers, suggestions, or new ways to code welcome
{
 $queryCentral = "INSERT INTO central (conName, conAddress, conCity,

conState, conZip, conPhone, schName, schAddress, schCity, schState, schZip, strName,

strCity, strState) VALUES('$regName', '$regAddress', '$regCity', '$regState',

'$regZip', '$regPhone', '$sclName', '$sclAddress', '$sclCity', '$sclState',

'$sclZip', '$stoName', '$stoCity', '$stoState')";

 mysql_query($queryCentral, $connection) or die("Query failed: ".

mysql_error($connection));
}


else
{
$queryUnknown = "INSERT INTO unknown (conName, conAddress, conCity, conState,

conZip, conPhone, schName, schAddress, schCity, schState, schZip, strName, strCity,

strState) VALUES('$regName', '$regAddress', '$regCity', '$regState', '$regZip',

'$regPhone', '$sclName', '$sclAddress', '$sclCity', '$sclState', '$sclZip',

'$stoName', '$stoCity', '$stoState')";
mysql_query($queryUnknown, $connection) or die("Query failed: ".

mysql_error($connection));
}

THIS WHAT FILE LOOKS LIKE //Any Problem solvers and suggestion welcome
=================================================
Begin Row 1
Grantsville Foodland Grantsville MD
Deep Creek Foodland Fresh Mc Henry MD
Oakland Foodland Oakland MD
Bridgeport Foodland Bridgeport WV
Grafton Foodland Grafton WV
Morgan's Foodland Fresh Kingwood WV
Petersburg Foodland Petersburg WV
Rainelle Foodland Rainelle WV
6th Avenue Foodland St. Albans WV
Weston Foodland Weston WV
Ambridge Foodland Ambridge PA
Curry Hollow Road Foodland Baldwin Pleasant Hills PA
Tusca Plaza Foodland Fresh Beaver PA
Bethel Park Foodland Bethel Park PA
Lebanon Shops Foodland Castle Shannon PA
Fatur's Foodland Delmont PA
Ford City Ford City PA
Glassport Foodland Glassport PA
Mount Royal Foodland Glenshaw PA
Grindstone Foodland Grindstone PA
Kittanning Foodland Kittanning PA
Mars Foodland Mars PA
Fifth Avenue Foodland Mc Keesport PA
Mckees Rocks Mckees Rocks PA
Monessen Foodland Fresh Monessen PA
Monongahela Foodland Monongahela PA
Great Valley Foodland N. Versailles PA
Gold Crown Foodland Nanty Glo PA
New Brighton Foodland New Brighton PA
J & J Foodland New Kensington PA
Brownsville Road Foodland Pittsburgh PA
Mt Washington Foodland Fresh Pittsburgh PA
Beechview Foodland Pittsburgh PA
Mcneilly Road Foodland Pittsburgh PA
Rochester Road Foodland Pittsburgh PA
Pines Plaza Foodland Pittsburgh PA
Point Marion Foodland Point Marion PA
Beulah Road Foodland Turtle Creek PA
Midtown Foodland Uniontown PA
Henderson Avenue Foodland Washington PA
Interstate Foodland Washington PA
Maiden Street Foodland Washington PA
Buttermilk Hollow Foodland West Mifflin PA
Village Foodland Fresh West Mifflin PA
Wellston Foodland Wellston OH
Westmoreland Foodland Fresh Huntington WV



--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Unknown

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to