Re: Not getting expected result from file()
| From: | kvigor | Date: | Mon, 11 Jun 2007 04:10:37 +0000 |
| Subject: | Re: Not getting expected result from file() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-256584@lists.php.net to get a copy of this message | ||
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"
""kvigor"" <k3cheese@insightbb.com> wrote in message
news:D4.00.40822.064CC664@pb1.pair.com...
> 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