[PHP] PHP MySQL Insert Syntax

2008-04-01 Thread kvigor
/*I'm trying to insert values from an array into MySQL DB but the insert
begins at the last record in the table and not at first record in the table.
I have added the cellSuffixes column after I already populated 30 records in
other columns*/

Code:

foreach($list as $key=>$value)
{
   $query = "INSERT INTO carriers (cellSuffixes) VALUES('$value')";
   mysql_query($query,$connex) or die("Query failed: ".
mysql_error($connex));
}
echo "done";
mysql_close($connex);

//I don't know what the sytax s/b to get the data to be inserted in the
first row of the column.




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



Re: [PHP] PHP MySQL Insert Syntax

2008-04-01 Thread kvigor
Thanks :-)


<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Insert is for a new row
>
> Alter or Update is for an exsisting row
>
>
>
>
>
> /*I'm trying to insert values from an array into MySQL DB but the insert
> begins at the last record in the table and not at first record in the 
> table.
> I have added the cellSuffixes column after I already populated 30 records 
> in
> other columns*/
>
> Code:
>
> foreach($list as $key=>$value)
> {
>   $query = "INSERT INTO carriers (cellSuffixes) VALUES('$value')";
>   mysql_query($query,$connex) or die("Query failed: ".
> mysql_error($connex));
> }
> echo "done";
> mysql_close($connex);
>
> //I don't know what the sytax s/b to get the data to be inserted in the
> first row of the column.
>
>
>
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php 



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



[PHP] Form Validation Issues

2007-05-23 Thread kvigor
Hi,

I have an issue with a particular if statement when I check 3 form fields 
for their value.  The problem is no matter what input is entered in the 
fields the output is the same.  I only added the 3 fields in question of the 
form to reduce heartache for the readers of this post.

Output always reads:
Please correct the following "State" fields.  Example: Enter state as 
Illinois or IL not ILLINOIS.
Consumer State

School State

Store State

The code is:
 "Consumer Name",
 "conAddress" => "Consumer Address",
 "conCity" => "Consumer City",
 "conState" => "Consumer State",
 "conZip" => "Consumer Zip Code",
 "conPhone" => "Consumer Phone",
 "schName" => "School Name",
 "schAddress" => "School Address",
 "schCity" => "School City",
 "schState" => "School State",
 "schZip"  => "School Zip Code",
 "strName" => "Store Name",
 "strCity" => "Store City",
 "strState" => "Store State");

//check data fields for correct data
foreach($_POST as $field => $value)
{
if($field == "conState" || $field == "schState" || $field == "strState") 
//if these 3 fields are entered
   {
   if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' || $value!= 
'AK' || $value != 'Arizona' || $value!= 'AZ' || $value != 'Arkansas' || 
$value!= 'AR' || $value != 'California' || $value!= 'CA' || $value != 
'Colorado' || $value!= 'CO' || $value != 'Conneticut' || $value!= 'CT' || 
$value != 'Delaware' || $value!= 'DE' || $value != 'Florida' || $value!= 
'FL' || $value != 'Georgia' || $value!=  'GA' || $value != 'Hawaii' || 
$value!=   'HI' || $value != 'Idaho' || $value!= 'ID' || $value != 
'Illinois' ||  $value!= 'IL' || $value != 'Inidiana' || $value!= 'IN' || 
$value != 'Iowa' || $value!= 'IA' || $value != 'Kansas' || $value!= 'KS' || 
$value != 'Kentucky' || $value!= 'KY' || $value != 'Louisiana' || $value!= 
'LA' || $value != 'Maine' || $value!= 'ME' || $value != 'Maryland' || 
$value!= 'MD' || $value != 'Massachusetts' || $value!= 'MA' || $value != 
'Michigan' || $value!= 'MI' || $value != 'Minnesota' || $value!= 'MN' || 
$value != 'Mississippi' || $value!= 'MS' || $value != 'Missouri' || $value!= 
'MO' || $value != 'Montana' || $value!= 'MT' || $value != 'Nebraska' || 
$value!= 'NE' || $value != 'Nevada' || $value!= 'NV' || $value != 'New 
Hampshire' || $value!= 'NH' || $value != 'New Jersey' || $value!= 'NJ' || 
$value != 'New Mexico' || $value!= 'NM' || $value != 'New York' || $value!= 
'NY' || $value != 'North Carolina' || $value!= 'NC' || $value != 'North 
Dakota' || $value!= 'ND' || $value != 'Ohio' || $value!= 'OH' || $value != 
'Oklahoma' || $value!= 'OK' || $value != 'Oregon' || $value!= 'OR' || $value 
!= 'Pennsylvania' || $value!= 'PA' || $value != 'Rhode Island' || $value!= 
'RI' || $value != 'South Carolina' || $value!= 'SC' || $value != 'South 
Dakota' || $value!= 'SD' || $value != 'Tennesee' || $value!= 'TN' || $value 
!= 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || $value 
!= 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' || 
$value != 'Washington' || $value!= 'WA' || $value != 'West Virginia' 
||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value != 
'Wyoming' || $value!= 'WY') //if they don't the match these

 {
   $state[$field] = "badstate"; //then
 }
  }//end check
}

 if(@sizeof($state) > 0)  //check size of array and display error message
 {
 echo "Please correct the following \"State\" 
fields.  Example: Enter state as Illinois or IL not 
ILLINOIS.";

  foreach($state as $field => $value) // display the fields where input is 
incorrect
  {
   echo "  {$label_array[$field]}";
  }
 }

echo " 
  
  *State:
  


*State:
  

*State:
  
   
   
   
 
  

 
  
  "; ?>

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



Re: [PHP] Form Validation Issues

2007-05-23 Thread kvigor
Thanks Dan,

Work like a dream.  I solute you.

""Daniel Brown"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 5/23/07, kvigor <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> I have an issue with a particular if statement when I check 3 form fields
>> for their value.  The problem is no matter what input is entered in the
>> fields the output is the same.  I only added the 3 fields in question of
>> the
>> form to reduce heartache for the readers of this post.
>>
>> Output always reads:
>> Please correct the following "State" fields.  Example: Enter state as
>> Illinois or IL not ILLINOIS.
>> Consumer State
>>
>> School State
>>
>> Store State
>>
>> The code is:
>> > $label_array = array ("conName" => "Consumer Name",
>>  "conAddress" => "Consumer Address",
>>  "conCity" => "Consumer City",
>>  "conState" => "Consumer State",
>>  "conZip" => "Consumer Zip Code",
>>  "conPhone" => "Consumer Phone",
>>  "schName" => "School Name",
>>  "schAddress" => "School Address",
>>  "schCity" => "School City",
>>  "schState" => "School State",
>>  "schZip"  => "School Zip Code",
>>  "strName" => "Store Name",
>>  "strCity" => "Store City",
>>  "strState" => "Store State");
>>
>> //check data fields for correct data
>> foreach($_POST as $field => $value)
>> {
>> if($field == "conState" || $field == "schState" || $field ==
>> "strState")
>> //if these 3 fields are entered
>>{
>>if($value != 'Alabama' || $value!= 'AL' || $value != 'Alaska' ||
>> $value!=
>> 'AK' || $value != 'Arizona' || $value!= 'AZ' || $value != 'Arkansas' ||
>> $value!= 'AR' || $value != 'California' || $value!= 'CA' || $value !=
>> 'Colorado' || $value!= 'CO' || $value != 'Conneticut' || $value!= 'CT' ||
>> $value != 'Delaware' || $value!= 'DE' || $value != 'Florida' || $value!=
>> 'FL' || $value != 'Georgia' || $value!=  'GA' || $value != 'Hawaii' ||
>> $value!=   'HI' || $value != 'Idaho' || $value!= 'ID' || $value !=
>> 'Illinois' ||  $value!= 'IL' || $value != 'Inidiana' || $value!= 'IN' ||
>> $value != 'Iowa' || $value!= 'IA' || $value != 'Kansas' || $value!= 'KS'
>> ||
>> $value != 'Kentucky' || $value!= 'KY' || $value != 'Louisiana' || 
>> $value!=
>> 'LA' || $value != 'Maine' || $value!= 'ME' || $value != 'Maryland' ||
>> $value!= 'MD' || $value != 'Massachusetts' || $value!= 'MA' || $value !=
>> 'Michigan' || $value!= 'MI' || $value != 'Minnesota' || $value!= 'MN' ||
>> $value != 'Mississippi' || $value!= 'MS' || $value != 'Missouri' ||
>> $value!=
>> 'MO' || $value != 'Montana' || $value!= 'MT' || $value != 'Nebraska' ||
>> $value!= 'NE' || $value != 'Nevada' || $value!= 'NV' || $value != 'New
>> Hampshire' || $value!= 'NH' || $value != 'New Jersey' || $value!= 'NJ' ||
>> $value != 'New Mexico' || $value!= 'NM' || $value != 'New York' ||
>> $value!=
>> 'NY' || $value != 'North Carolina' || $value!= 'NC' || $value != 'North
>> Dakota' || $value!= 'ND' || $value != 'Ohio' || $value!= 'OH' || $value 
>> !=
>> 'Oklahoma' || $value!= 'OK' || $value != 'Oregon' || $value!= 'OR' ||
>> $value
>> != 'Pennsylvania' || $value!= 'PA' || $value != 'Rhode Island' || 
>> $value!=
>> 'RI' || $value != 'South Carolina' || $value!= 'SC' || $value != 'South
>> Dakota' || $value!= 'SD' || $value != 'Tennesee' || $value!= 'TN' ||
>> $value
>> != 'Texas' || $value!= 'TX' || $value != 'Utah' || $value!= 'UT' || 
>> $value
>> != 'Vermont' || $value!= 'VT' || $value != 'Virginia' || $value!= 'VA' ||
>> $value != 'Washington' || $value!= 'WA' || $value != 'West Virginia'
>> ||$value!= 'WV' || $value != 'Wisconsin' || $value!= 'WI' || $value !=
>> 'Wyoming' || $value!= 'WY') //if they don't the match these
>>
>>  {
>>$state[$field] = "badstate"; //then
>>  }
>>   }//end check
>> }
>>
>> if(@sizeof($state) > 0)  //check size of array and display error message
>> {
>>  echo "Please correct the following
>> \"State\"
>> fields.  Example: Enter state as Illinois or IL not
>> ILLINOIS.";
>>
>>   foreach($state as $field => $value) // display the fields where input 
>> is
>> incorrect
>>   {
>>echo "  {$label_array[$field]}";
>>   }
>> }
>>
>> echo " 
>>   
>>   *State:
>>   > value='{$_POST['conState']}' />
>>
>>
>> *State:
>>   > value='{$_POST['schState']}'/>
>>
>> *State:
>>   > value='{$_POST['strState']}' />
>>
>>
>>
>>  
>>   
>>
>>  
>>   
>>   "; ?>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>You're doing all OR statements.  This means "if it's not this or it's
> not this or it's not this or it's not this"
>
>Replace the OR ( || ) with AND ( && ) throughout the if() clause and it
> should work just fine.
>
> -- 
> Daniel P. Brown
> [office] (570-) 587-7080 Ext. 272
> [mobile] (570-) 766-8107
> 

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



[PHP] Cant set info in DB...HELP

2007-06-01 Thread kvigor
Hello,

I'm using phpMyAdmin and I can't get any of my form data into the database. 
It returns message: "MySQL returned an empty result set" w/in phpMyAdmin 
GUI.

However I get no errors on screen when form info is submitted.

What I have done to solve issue: drop DB and create new.
Review form vars and SQL statements can't find errors...help

Please help...

//=FORM==
 
  
 
 Consumer Information
 
 *Name:
  


 *Address:
  


 *City:
  

 

*State:
  

 *Zip:
  
   
   
 *Phone:
  
   
   
   
School Nomination

Information 
   
*Name:
  
   
   
*Address:
  
   
   
*City:
  

*State:
  

*Zip:
  
   
   

Store Shopped At


*Name:
  
   
   
   
*City:
  

*State:
  
   
   
   
 
  

 
  
  ";
//END==FORM

echo" ";
//===striptags=and=trim===
   $regName = trim(strip_tags($_POST['conName'])); $regAddress

= trim(strip_tags($_POST['conAddress']));
   $regCity = trim(strip_tags($_POST['conCity'])); $regState =

trim(strip_tags($_POST['conState']));
   $regZip = trim(strip_tags($_POST['conZip'])); $regPhone =

trim(strip_tags($_POST['conPhone']));

   $sclName = trim(strip_tags($_POST['schName'])); $sclAddress

= trim(strip_tags($_POST['schAddress']));
   $sclCity = trim(strip_tags($_POST['schCity'])); $sclState =

trim(strip_tags($_POST['schState']));
   $sclZip = trim(strip_tags($_POST['schZip']));

   $stoName = trim(strip_tags($_POST['strName'])); $stoCity =

trim(strip_tags($_POST['strCity']));
   $stoState = trim(strip_tags($_POST['strState']));
//==end=striptags=and=trim===

//==Begin dbPopulation of Form 
data

$dbserver = "localhost";
$dbuser = "root";
$dbpassword = "";
$dbname = "theDB";

$connection = mysqli_connect($dbserver, $dbuser, $dbpassword, $dbname) or 
die

("Could not connect to the Server. Contact your Network Administrator or 
your Web

Programmer");

$insert_query = "INSERT INTO contestants (conName, conAddress, conCity, 
conState,

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

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

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

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

mysqli_query($connection,$insert_query); ?>
//==End dbPopulation of Form 
data 

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



Re: [PHP] Cant set info in DB...HELP

2007-06-03 Thread kvigor
Thanks All.

Made the changes and just like Ambien it worked like a Dream.

I found out that I had a typo in my DB and missing ")" I corrected it. All
is well.


"Tijnema" < wrote in message
news:[EMAIL PROTECTED]
> On 6/3/07, Stut <[EMAIL PROTECTED]> wrote:
>> K. Hayes wrote:
>> > What "lists" are you referring to?  Also this is how the examples show
>> > I've seen.
>>
>> I mean hit "Reply to all" in your mail client. That way you include the
>> email address of the PHP General mailing list so everyone, including the
>> archives, can see your reply.
>>
>> > I know this is basic general stuff but I try many times before posting,
>> > and I have followed all directions given.
>>
>> Change the following line...
>>
>> > mysqli_query($connection,$sql_query); ?>
>>
>> to...
>>
>> mysqli_query($connection,$sql_query)
>> or die("Query failed: ".mysqli_error($connection);
>
> you're missing a ) here, it should be:
> mysqli_query($connection,$sql_query)
> or die("Query failed: ".mysqli_error($connection))
>
> Tijnema
>>
>> If you still get no output, check error_reporting and display_errors in
>> your php.ini file to make sure you are seeing at least errors and
>> warnings.
>>
>> -Stut
>>
>> > ===END NEW
>> > CODE=
>> >
>> >
>> > - Original Message - From: "Stut" <[EMAIL PROTECTED]>
>> > To: "K.Hayes" <[EMAIL PROTECTED]>
>> > Cc: "php-general" 
>> > Sent: Saturday, June 02, 2007 9:52 PM
>> > Subject: Re: [PHP] Cant set info in DB...HELP
>> >
>> >
>> >> Please include the list on all replies.
>> >>
>> >> K.Hayes wrote:
>> >>> I don't know if I'm escaping the 'vars correctly'.  If I'm wrong can
>> >>> you
>> >>> give me an example?
>> >> 
>> >>> $sql_query = "INSERT INTO contestants (conName, conAddress, conCity,
>> >>> conState, conZip, conPhone, schName, schAddress, schCity, schState,
>> >>> schZip,
>> >>> strName, strCity, strState) VALUES('$regName', '$regAddress',
>> >>> '$regCity',
>> >>> '$regState', '$regZip', '$regPhone', '$sclName', '$sclName',
>> >>> '$sclCity',
>> >>> 'sclState', '$sclZip', '$stoName', '$stoCity', '$stoState')";
>> >>> $insert_query = mysqli_real_escape_string($connection, $sql_query);
>> >>>
>> >>> mysqli_query($connection,$insert_query); ?>
>> >>
>> >> No, this is not the right way. I suggest you read the manual page on
>> >> mysqli_real_escape_string (http://php.net/mysqli_real_escape_string).
>> >> You need to run it on every variable you are using *in* the SQL query,
>> >> not on the SQL query itself.
>> >>
>> >> Google for a php mysqli tutorial - all this stuff is very basic and
>> >> should be covered by most tutorials you'll find.
>> >>
>> >> -Stut
>
>>

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



[PHP] Not getting expected result from file()

2007-06-10 Thread kvigor
Hello,

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

My problem is I expect  the condition to be true but info but my DB isn't 
populated as I in the right DB...
=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 

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



[PHP] Re: Not getting expected result from file()

2007-06-10 Thread kvigor
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"" <[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 

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



[PHP] Re: Not getting expected result from file()

2007-06-10 Thread kvigor
OK, I trimmed the elements in the array. using var_dump() it shows strings 
are identical, however nothing is storing in DB still.

view new code
=//doesn't store in central still, also 
shows no MySQL errors.
$theFileArray = file('C:\htdocs\folder1\file.txt');

function trim_value(&$value)
{
$value = trim($value);
}

array_walk($theFileArray, 'trim_value');


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

}
 if(in_array($storeInfo, $theFileArray))
 {
  $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));
}
=

"David Robley" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>
>> Hello,
>>
>> I'm using the file function create an array.  I'm using a value from a
>> form to see if it matches in elements in the array.
>>
>> My problem is I expect  the condition to be true but info but my DB isn't
>> populated as I in the right DB...
>> =Code
>> Begins==
>> $theFileArray = file('C:\htdocs\folder1\file.txt');
>>
>
> Your problem starts here - file returns the file in an array. Each element
> of the array corresponds to a line in the file, with the newline still
> attached. When you compare to a string without the newline at the end, the
> comparison fails.
>
> If you have php > 5.0.0 you can use the FILE_IGNORE_NEW_LINES flag in the
> file() arguments, otherwise use trim() to remove trailing whitespace from
> the array elements.
>
>
>
> Cheers
> -- 
> David Robley
>
> "I hate playing craps," Tom said dicily.
> Today is Boomtime, the 16th day of Confusion in the YOLD 3173. 

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



[PHP] Re: Not getting expected result from file()

2007-06-10 Thread kvigor
Trimmed elements in the array.  I still can't get it to store in central 
table.  No MySQL errors either. :-(
 (Also, all form values are escaped.) Strings compared in if condition are 
now identical.


newcode
===
theFileArray = file('C:\htdocs\folder1\file.txt');

function trim_value(&$value)
{
$value = trim($value);
}

array_walk($theFileArray, 'trim_value');


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

 if(in_array($stringOne, $theFileArray)) // string were identical after I 
trimmed an did var_dump on $stringOne and $theFileArray[2]
 {
  $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));
}

"David Robley" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>
>> Hello,
>>
>> I'm using the file function create an array.  I'm using a value from a
>> form to see if it matches in elements in the array.
>>
>> My problem is I expect  the condition to be true but info but my DB isn't
>> populated as I in the right DB...
>> =Code
>> Begins==
>> $theFileArray = file('C:\htdocs\folder1\file.txt');
>>
>
> Your problem starts here - file returns the file in an array. Each element
> of the array corresponds to a line in the file, with the newline still
> attached. When you compare to a string without the newline at the end, the
> comparison fails.
>
> If you have php > 5.0.0 you can use the FILE_IGNORE_NEW_LINES flag in the
> file() arguments, otherwise use trim() to remove trailing whitespace from
> the array elements.
>
>
>
> Cheers
> -- 
> David Robley
>
> "I hate playing craps," Tom said dicily.
> Today is Boomtime, the 16th day of Confusion in the YOLD 3173. 

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



[PHP] Re: Not getting expected result from file()

2007-06-11 Thread kvigor
Found out the issue this afternoon.  I realized that my .txt file was tab 
delimited and not space delimited.  So I changed $space to equal $tab and 
query was successful! All is working now. Thanks to all who replied.  I 
appreciate all.

"David Robley" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>
>> Hello,
>>
>> I'm using the file function create an array.  I'm using a value from a
>> form to see if it matches in elements in the array.
>>
>> My problem is I expect  the condition to be true but info but my DB isn't
>> populated as I in the right DB...
>> =Code
>> Begins==
>> $theFileArray = file('C:\htdocs\folder1\file.txt');
>>
>
> Your problem starts here - file returns the file in an array. Each element
> of the array corresponds to a line in the file, with the newline still
> attached. When you compare to a string without the newline at the end, the
> comparison fails.
>
> If you have php > 5.0.0 you can use the FILE_IGNORE_NEW_LINES flag in the
> file() arguments, otherwise use trim() to remove trailing whitespace from
> the array elements.
>
>
>
> Cheers
> -- 
> David Robley
>
> "I hate playing craps," Tom said dicily.
> Today is Boomtime, the 16th day of Confusion in the YOLD 3173. 

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



[PHP] Convert Date time into Seconds

2007-06-23 Thread kvigor
Good Day,

I'm chech if 24hrs has passed between these 2 datetimes:

$dTime1 = 2007-06-21 11:08:09;

$dTime2 = 2007-06-22 07:08:09;

I'd really like to convert the datetimes above into a format I can do 
regular math them.

Browsing around I've found the following code.  But both weren't clear on 
what to pass to them.  Because when I pass a datetime var to them and echo 
the value I get no output please help.
==
function datetime_to_epoch($date)
{
  $break = explode(" ", $date);
  $datebreak = explode("-", $break[0]);
  $time = explode(":", $break[1]);
  $epoch = date("U", 
mktime($time[0],$time[1],$time[2],$datebreak[1],$datebreak[2],$datebreak[0]));
  $datetime = date("Y-m-d H:i:s", 
mktime($time[0],$time[1],$time[2],$datebreak[1],$datebreak[2],$datebreak[0]));
}
?>
===
function convert_datetime($varStamp) {

list($date, $time) = explode(' ', $str);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);

$timestamp = mktime($hour, $minute, $second, $month, $day, $year);

return $timestamp;
}

//If anyone could elaborate, would be appreciated.

 

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



Re: [PHP] Convert Date time into Seconds

2007-06-23 Thread kvigor
Cool,

Like Ambien, It worked like a dream.


"Robert Cummings" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Sat, 2007-06-23 at 21:29 -0500, kvigor wrote:
>> Good Day,
>>
>> I'm chech if 24hrs has passed between these 2 datetimes:
>>
>> $dTime1 = 2007-06-21 11:08:09;
>>
>> $dTime2 = 2007-06-22 07:08:09;
>>
>> I'd really like to convert the datetimes above into a format I can do
>> regular math them.
>
> 
> echo ($foo = strtotime( '2007-06-21 11:08:09' ))."\n";
> echo date( 'Y/m/d H:i:s', $foo )."\n";
>
> ?>
>
> $foo contains a unix timestamp (the time in seconds since the Epoch).
>
> Cheers,
> Rob.
> -- 
> ..
> | InterJinn Application Framework - http://www.interjinn.com |
> ::
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for   |
> | creating re-usable components quickly and easily.  |
> `' 

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



[PHP] Selecting Rows Based on Row Values Being in Array

2007-06-29 Thread kvigor
Hello All,

I'm attempting to return rows from a mysql DB based on this criteria:

I have a list, in the form of an array that I need to compare against each 
row
in the table.  Where theres a match I need that entire row returned.

e.g.$varListof 3outOf_10Fields = array(6blue40lbs, 7orange50lbs, 
8orange60lbs, 9purple70lbs);

The array contains 3 of the db row fields in 1 value. However there are 10 
fields/columns in the table.

===
what table looks like  |
===
  size   colorweight
ROW 1| value1 | value1 | value1 | value1 | value1 | value1 |

So how could I set up a query that would SELECT the entire row, if the row 
contained $varListof 3outOf_10Fields[1].

Open to any suggestions or work arounds.  I'm playing with extract() but 
code is too crude to even post.

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



Re: [PHP] Selecting Rows Based on Row Values Being in Array

2007-07-01 Thread kvigor
Jim,

Please excuse the ignorance, I'm a newbie, but I'm only use to simple 
SELECT, INSERT statements.


Your original code: $SQL = "SELECT * FROM my_Table WHERE CONCAT(value1, 
value2, value3) IN ('".join("','", $list)."')

OK, I get everything up to  the ('''.join(''','''$list).''')
I'm guessing that the .join( ). putting together some values, but I don't 
know what
also the .join( ). is to be preceded by something... I don't know what. 
//Forgive my ignorance, I'll can get it.

Also the .join( ). what is this doing I looked at the PHP and MySQL function 
of each, and haven't seen comparable code.

I'm asking because I don't know where we're telling the code to compare the 
values.

You stated...
>>> and create one string from them
Where do I give the name to the string?

So this is where I am so far:

$sql = "SELECT* FROM table WHERE CONCAT(size,color,weight) IN( )";


"Jim Lucas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> K. Hayes wrote:
>> Will do.  Thanks.
>>
>>
>> - Original Message - From: "Jim Lucas" <[EMAIL PROTECTED]>
>> To: "kvigor" <[EMAIL PROTECTED]>
>> Cc: 
>> Sent: Saturday, June 30, 2007 1:46 AM
>> Subject: Re: [PHP] Selecting Rows Based on Row Values Being in Array
>>
>>
>>> kvigor wrote:
>>>> Hello All,
>>>>
>>>> I'm attempting to return rows from a mysql DB based on this criteria:
>>>>
>>>> I have a list, in the form of an array that I need to compare against 
>>>> each row
>>>> in the table.  Where theres a match I need that entire row returned.
>>>>
>>>> e.g.$varListof 3outOf_10Fields = array(6blue40lbs, 7orange50lbs, 
>>>> 8orange60lbs, 9purple70lbs);
>>>>
>>>> The array contains 3 of the db row fields in 1 value. However there are 
>>>> 10 fields/columns in the table.
>>>>
>>>> ===
>>>> what table looks like  |
>>>> ===
>>>>   size   colorweight
>>>> ROW 1| value1 | value1 | value1 | value1 | value1 | value1 |
>>>>
>>>> So how could I set up a query that would SELECT the entire row, if the 
>>>> row contained $varListof 3outOf_10Fields[1].
>>>>
>>>> Open to any suggestions or work arounds.  I'm playing with extract() 
>>>> but code is too crude to even post.
>>>>
>>> I would suggest approaching the problem with a slightly different 
>>> thought.
>>>
>>> just have the sql concat() the columns together and then compare.
>>>
>>> something like this should do the trick
>>>
>>> $list = array(
>>> '6blue40lbs',
>>> '7orange50lbs',
>>> '8orange60lbs',
>>> '9purple70lbs',
>>> );
>>>
>>> $SQL = "
>>> SELECT *
>>> FROM my_Table
>>> WHERE CONCAT(value1, value2, value3) IN ('".join("','", $list)."')
>>> ";
>>>
>>> mysql_query($SQL);
>>>
>>> this should take, for each row in the DB, value1 + value2 + value3 and 
>>> create one string from them, then it will compare each string in the
>>> IN (...)  portion to each entry in the $list array().
>>>
>>> Let me know if you need any further help
> one other thing, make sure that you run each of the values in the $list 
> array() through mysql_real_escape_string().  That way it is all nicely 
> encoded for the SQL statement. 

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



[PHP] Removing Spaces from Array Values

2007-07-02 Thread kvigor
Need to remove all spaces from Array Values... And this doesn't work.

This is similar info that's within array values: $someArray[0] = "PHP is 
awesome";s/b PHPisawesome
This is similar info that's within array values: $someArray[1] = "The Toy 
Boat";s/b TheToyBoat

Begin Code===
$num = count($someArray);

for($num = 0; $cntr < $num; $cntr++)
{
 str_replace(' ','',$someArray[$num]);
 echo "$someArray[$num]";
}
End Code=== 

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



Re: [PHP] Removing Spaces from Array Values

2007-07-02 Thread kvigor
Got I'm my bad I really feel SHEEPISH...  s/b have done '$someArray ='
Re-read what I thought I read a it worked like a dream.

Thanks Adam


"Adam Schroeder" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> The function str_replace() DOES NOT change the parameter.  Rather, 
> str_replace() returns the desired string.  Try changing your code to:
>
>
> for($num = 0; $cntr < $num; $cntr++)
> {
> $someArray[$num] = str_replace(' ','',$someArray[$num]);
> echo "$someArray[$num]";
> }
>
>
>
> http://us.php.net/manual/en/function.str-replace.php
>
>
> Adam
>
> kvigor wrote:
>
>>Need to remove all spaces from Array Values... And this doesn't work.
>>
>>This is similar info that's within array values: $someArray[0] = "PHP is 
>>awesome";s/b PHPisawesome
>>This is similar info that's within array values: $someArray[1] = "The Toy 
>>Boat";s/b TheToyBoat
>>
>>Begin Code===
>>$num = count($someArray);
>>
>>for($num = 0; $cntr < $num; $cntr++)
>>{
>> str_replace(' ','',$someArray[$num]);
>> echo "$someArray[$num]";
>>}
>>End Code===
>> 

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



Re: [PHP] Selecting Rows Based on Row Values Being in Array

2007-07-02 Thread kvigor
Ok Jim,

This is what I have so far and I'm still working it out.

$in_list = "".join('',$someArrayList);  // do I really need to concatenate 
or separate anything here since my array values will be '7orange50lbs'? // 
this is the format I want.

$query_One = "SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
IN({$in_list})";// size, color, weight are my column names
$result = mysql_query($query_One ,$connection) or die("Query failed: ". 
mysql_error($connection));
$row = mysql_fetch_array($result);

This is the error I get back from the query:
Query failed: Unknown column '6blue40lbs' in 'where clause'// where am I 
going wrong?
==
"Jim Lucas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>> Jim,
>>
>> Please excuse the ignorance, I'm a newbie, but I'm only use to simple 
>> SELECT, INSERT statements.
>>
>>
>> Your original code: $SQL = "SELECT * FROM my_Table WHERE CONCAT(value1, 
>> value2, value3) IN ('".join("','", $list)."')
>
> This can be broken down into smaller parts so to explain by example.
>
> # This is to clean the input values for the SQL statement
> function mysql_clean($value) {
> return mysql_real_escape_string($value);
> }
>
> # Define your list of values to compare to
> $list = array(
> '6blue40lbs',
> '7orange50lbs',
> '8orange60lbs',
> '9purple70lbs',
> );
>
> # You will want to do something like this with the values of the $list
> # array just to make sure they are clean: reference the function above
> array_walk($list, 'mysql_clean');
>
> # This will return a string formated like this.
> # '6blue40lbs','7orange50lbs','8orange60lbs','9purple70lbs'
> $IN_VALUE = "'".join("','", $list)."'";
>
> $SQL = "SELECT *
> FROM my_Table
> WHERE CONCAT(value1, value2, value3)
> IN ({$IN_VALUE})";
>
> # The final query string will look like this
> SELECT *
> FROM my_Table
> WHERE CONCAT(value1, value2, value3)
> IN ('6blue40lbs','7orange50lbs','8orange60lbs','9purple70lbs')
>
> # Now run this through your query function and get the results
> $results = mysql_query($SQL) OR die('SQL Failure: '.$SQL);
>
> So basically what we have is a comparison that is based off the output of 
> the CONCAT() function that creates one string out of value1, value2, 
> value3 and then compares that with each of the values listed within the 
> parenthesis.  the IN (...) part of the SQL statement tells SQL that it is 
> getting a list of values that it should compare the concat() value 
> against.
>
> Doing it this way, will allow you to only run one query instead of running 
> one per value that you want to compare against.  As you can tell, as your 
> data set grows your multiple queries would drag your DB to a halt
>
> Hope this explains it.
>
> Let me know if you need further explanation.
>
>>
>> OK, I get everything up to  the ('''.join(''','''$list).''')
>> I'm guessing that the .join( ). putting together some values, but I don't 
>> know what
>> also the .join( ). is to be preceded by something... I don't know what. 
>> //Forgive my ignorance, I'll can get it.
>>
>> Also the .join( ). what is this doing I looked at the PHP and MySQL 
>> function of each, and haven't seen comparable code.
>>
>> I'm asking because I don't know where we're telling the code to compare 
>> the values.
>>
>> You stated...
>>>>> and create one string from them
>> Where do I give the name to the string?
>>
>> So this is where I am so far:
>>
>> $sql = "SELECT* FROM table WHERE CONCAT(size,color,weight) IN( )";
>>
>>
>> "Jim Lucas" <[EMAIL PROTECTED]> wrote in message 
>> news:[EMAIL PROTECTED]
>>> K. Hayes wrote:
>>>> Will do.  Thanks.
>>>>
>>>>
>>>> - Original Message - From: "Jim Lucas" <[EMAIL PROTECTED]>
>>>> To: "kvigor" <[EMAIL PROTECTED]>
>>>> Cc: 
>>>> Sent: Saturday, June 30, 2007 1:46 AM
>>>> Subject: Re: [PHP] Selecting Rows Based on Row Values Being in Array
>>>>
>>>>
>>>>> kvigor wrote:
>>>>>> Hel

Re: [PHP] Removing Spaces from Array Values

2007-07-02 Thread kvigor
I meant to say:  Got It, My bad, I really feel SHEEPISH... should have 
done...

This is what happens when you're trying to code with a migraine, You start 
speaking another language.

Thanks Again

""kvigor"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Got I'm my bad I really feel SHEEPISH...  s/b have done '$someArray ='
> Re-read what I thought I read a it worked like a dream.
>
> Thanks Adam
>
>
> "Adam Schroeder" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> The function str_replace() DOES NOT change the parameter.  Rather, 
>> str_replace() returns the desired string.  Try changing your code to:
>>
>>
>> for($num = 0; $cntr < $num; $cntr++)
>> {
>> $someArray[$num] = str_replace(' ','',$someArray[$num]);
>> echo "$someArray[$num]";
>> }
>>
>>
>>
>> http://us.php.net/manual/en/function.str-replace.php
>>
>>
>> Adam
>>
>> kvigor wrote:
>>
>>>Need to remove all spaces from Array Values... And this doesn't work.
>>>
>>>This is similar info that's within array values: $someArray[0] = "PHP is 
>>>awesome";s/b PHPisawesome
>>>This is similar info that's within array values: $someArray[1] = "The Toy 
>>>Boat";s/b TheToyBoat
>>>
>>>Begin Code===
>>>$num = count($someArray);
>>>
>>>for($num = 0; $cntr < $num; $cntr++)
>>>{
>>> str_replace(' ','',$someArray[$num]);
>>> echo "$someArray[$num]";
>>>}
>>>End Code===
>>> 

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



Re: [PHP] Selecting Rows Based on Row Values Being in Array

2007-07-03 Thread kvigor
Jim,

Thanks for all you help.  Tell me where to mail you the check "seriously". 
If we get this right I'll owe you.

OK, the query string now looks like you said it would.  However Query isn't 
returning a match.
//DETAILS=

My $list array looks like this one echo'd:

$list[0] =7orange50lbs
$list[1] =8purple60lbs


Now when I do this:

$query_One= "SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
IN({$in_list})";

$result = mysql_query($query_One,$connection) or die("Query failed: ". 
mysql_error($connection));
$row = mysql_fetch_assoc($result);

  while($row = mysql_fetch_assoc($result))
  {extract($row);
  echo "
  $count
  $size
  $color
  $weight
  
  ";
  }
No rows are returned to the screen.  I know I should at least have 2 rows 
return because my TABLE has 2 rows in it and both rows are in $in_list[0] 
and[1].

  size  color   weight
Row1 looks like: 7 orange 50lbs//This is from phpMyAdmin table 
export
Row2 looks like: 8 purple 60lbs//This is from phpMyAdmin table 
export


I get no MySQL errors either.  So I'm wondering why aren't rows returning?
//END DETAILS==


"Jim Lucas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>> Ok Jim,
>>
>> This is what I have so far and I'm still working it out.
>>
>> $in_list = "".join('',$someArrayList);  // do I really need to 
>> concatenate
> it needs to be
>
> $in_list = "'".join("','",$someArrayList)."'"; // you need the quotes!!
>
>> or separate anything here since my array values will be '7orange50lbs'? 
>> // this is the format I want.
> You are going wrong right here.  First off you took out all the quoting
>
> Your search items must be quoted and separated by commas.  Remember, we 
> want it to check a list/array() of items
>
> $in_list must look like this when done 'item1','item2','item3'
>
> in SQL, this is a list.
>
>>
>> $query_One = "SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
>> IN({$in_list})";// size, color, weight are my column names
>
> if you echo $query_One , what do you get?
>
>> $result = mysql_query($query_One ,$connection) or die("Query failed: ". 
>> mysql_error($connection));
> before you run the fetch, you need to double check that you got something 
> back, otherwise you will get an error from php.
>
> if ( mysql_num_rows($results) > 0 ) {
> while ( $row = mysql_fetch_array(
> } else {
> echo "No results";
> }
>
>> $row = mysql_fetch_array($result);
>
> and I would recommend that you use either *_assoc() or *_row() instead of 
> *_array().
> Doesn't use as much memory, and your resulting $row variable doesn't have 
> two of what you are looking for.
>
>>
>> This is the error I get back from the query:
>> Query failed: Unknown column '6blue40lbs' in 'where clause'
>
> This is because you took out the quotes from above.  Put them back and it 
> might just work.
>
> SQL will see the un-quoted 6blue40lbs and think that it is a string.
> If it was quoted, it would not.
>
> // where am I
>> going wrong?
>
> -- 
> Jim Lucas
>
>"Some men are born to greatness, some achieve greatness,
>and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare 

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



Re: [PHP] Selecting Rows Based on Row Values Being in Array

2007-07-04 Thread kvigor
>>where is the part that it join()'s things together?
it's: $in_list = "'".join("','",$list)."'";

>>what is the output of the join() call
it's: '7orange50lbs','8purple60lbs' //once echo'd


$query_One = "SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
IN({$in_list})";

This is the results of $query_One:

PHP echo returns:
SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
IN('7orange50lbs','8purple60lbs)


MySQL returns:
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0008 sec)
SQL query:
SELECT *
FROM shoe
WHERE CONCAT( size, color, weight )
IN (SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
IN('7orange50lbs','8purple60lbs')

Row 1 and Row 2 should return because:
columns 9-11 are equal to:
7 orange 50lbs
8 purple 60lbsHope all this helps
===
"Jim Lucas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>> Jim,
>>
>> Thanks for all you help.  Tell me where to mail you the check 
>> "seriously". If we get this right I'll owe you.
>>
>> OK, the query string now looks like you said it would.  However Query 
>> isn't returning a match.
>> //DETAILS=
>>
>> My $list array looks like this one echo'd:
>>
>> $list[0] =7orange50lbs
>> $list[1] =8purple60lbs
>>
>>
> where is the part that it join()'s things together?
> what is the output of the join() call
>
>> Now when I do this:
>>
>> $query_One= "SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
>> IN({$in_list})";
>
> echo $query_One;
>
> and show me the results of the echo
>
> also, run this SQL statement in phpmyadmin and see what it returns
>
>>
>> $result = mysql_query($query_One,$connection) or die("Query failed: ". 
>> mysql_error($connection));
>
> get rid of this, basically you are throwing away your first row of 
> results.
>> $row = mysql_fetch_assoc($result);
>>
>>   while($row = mysql_fetch_assoc($result))
>>   {extract($row);
>>   echo "> class='tborder'>
>>   > align='left' class='tcat'>$count
>>   $size
>>   $color
>>   $weight
>>   
>>   ";
>>   }
>> No rows are returned to the screen.  I know I should at least have 2 rows 
>> return because my TABLE has 2 rows in it and both rows are in $in_list[0] 
>> and[1].
>>
>>   size  color   weight
>> Row1 looks like: 7 orange 50lbs//This is from phpMyAdmin 
>> table export
>> Row2 looks like: 8 purple 60lbs//This is from phpMyAdmin 
>> table export
>>
>>
>> I get no MySQL errors either.  So I'm wondering why aren't rows 
>> returning?
>> //END 
>> DETAILS==
>
> -- 
> Jim Lucas
>
>"Some men are born to greatness, some achieve greatness,
>and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare 

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



Re: [PHP] Selecting Rows Based on Row Values Being in Array

2007-07-05 Thread kvigor
Sorry,
That was a typo there's on one IN clause.
here is how it reads: SELECT * FROM central WHERE 
CONCAT(strName,strCity,strState) IN('7orange50lbs','8purple60lbs').

So in my table I have 8 in size column, purple in color column, and 60lbs in 
weight column.

Since the concatenated value will be 8purple60lbs, shouldn't MySQL return 
that row?  Thanks for your patience.

"Jim Lucas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>>>> where is the part that it join()'s things together?
>> it's: $in_list = "'".join("','",$list)."'";
> Good
>
>>
>>>> what is the output of the join() call
>> it's: '7orange50lbs','8purple60lbs' //once echo'd
> Fine
>
>>
>>
>> $query_One = "SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
>> IN({$in_list})";
>>
>> This is the results of $query_One:
>>
>> PHP echo returns:
>> SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
>> IN('7orange50lbs','8purple60lbs)
>>
>>
>> MySQL returns:
>> MySQL returned an empty result set (i.e. zero rows). (Query took 0.0008 
>> sec)
>> SQL query:
>> SELECT *
>> FROM shoe
>> WHERE CONCAT( size, color, weight )
>> IN (SELECT * FROM shoe WHERE CONCAT(size,color,weight) 
>> IN('7orange50lbs','8purple60lbs')
>
> ???
>
> What is wrong with the above statement?
>
> This should be an easy one for you to figure out?
>
>
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
> .
>
> Give up?
>
> Well, looks like you are inserting the sql statement inside it self
>
> It should look like this
>
> SELECT *
> FROM shoe
> WHERE CONCAT( size, color, weight ) IN('7orange50lbs','8purple60lbs')
>
>
> not
>
> SELECT *
> FROM shoe
> WHERE CONCAT( size, color, weight )
> IN (SELECT * FROM shoe WHERE CONCAT(size,color,weight)
> IN('7orange50lbs','8purple60lbs')
>
> Notice the sub-select???
>
> Find where you are inserting the SQL into itself and remove it, and you 
> might have the answer to your problems.
>
> Jim 

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



[PHP] Reading Error: socket '/var/lib/mysql/mysql.sock'

2007-07-06 Thread kvigor
Can't connect to local MySQL server through socket 
'/var/lib/mysql/mysql.sock' (2)

FYI I did this to solved the problem but it didn't work: 
http://webyog.com/forums/lofiversion/index.php/t1367.html  the only thing is 
that I'm running MySQL 5.0 (I have a my.ini not my.cfg) and I put the var 
folder in the following dir C:\Program Files\MySQL\MySQL Server 
5.0\var\lib\mysql. I also modified my PHP.ini to reflect new socket 
location.

What really bothers me is that all was fine until yesterday and my AMP setup 
for localhost works fine.  Only when I upload to Webhost i get the socket 
error
The only thing I did was add the following include file @ the top of all my 
admin pages.

include file

//===
AdminForm looks like:
//===

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
http://www.w3.org/1999/xhtml";>


ADMIN LOGIN











 

 
  
  
Username and/or Password are 
Incorrect";}?>

  
 

 
  
  USERNAME
   

  
  
  
  PASSWORD
  

  
  
  
  
  
  
  
  




END ADMIN FORM===

Also if I change the AdminFormVal.php beginning 'if' clause to $_SESSION 
instead of $_POST, I mysteriously don't get the mysql.sock error. But script 
does nothing when I do that of course.
===
AdminFormVal.php file looks like this:

 0) //password was found
  {
   $_SESSION['auth'] = "yes";
   header("Location: Admin.php");
  }
 }
 else
 {
  $_SESSION['auth'] = "no";
  $_SESSION['sight'] = "error";
  header("Location: AdminForm.php");
 }
}
?>
===

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



[PHP] Re: Reading Error: socket '/var/lib/mysql/mysql.sock'

2007-07-06 Thread kvigor
PROBLEM SOLVED had wrong db connection file on HOST SERVER.


""kvigor"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Can't connect to local MySQL server through socket 
> '/var/lib/mysql/mysql.sock' (2)
>
> FYI I did this to solved the problem but it didn't work: 
> http://webyog.com/forums/lofiversion/index.php/t1367.html  the only thing 
> is that I'm running MySQL 5.0 (I have a my.ini not my.cfg) and I put the 
> var folder in the following dir C:\Program Files\MySQL\MySQL Server 
> 5.0\var\lib\mysql. I also modified my PHP.ini to reflect new socket 
> location.
>
> What really bothers me is that all was fine until yesterday and my AMP 
> setup for localhost works fine.  Only when I upload to Webhost i get the 
> socket error
> The only thing I did was add the following include file @ the top of all 
> my admin pages.
> 
> include file
>  session_start();
> if($_SESSION['auth'] != "yes")
> {
> header("Location: AdminForm.php");
> exit();
> }
> ?>
> //===
> AdminForm looks like:
> //===
> 
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
> 
> ADMIN LOGIN
> 
> <!--
> .style3 {font-size: 11pt}
> body {
> background-color: #F5F5F5;
> }
> -->
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
> 
>   />
>  
>  if(@$_SESSION['sight'] == "error")
> {echo "Username and/or Password are 
> Incorrect";}?>
> 
>  
> 
>
> 
>  
>  USERNAME
>   
>
>  
>  
>  
>  PASSWORD
>  
>
>  
>  
>  
>  
>  
>  
>  
>  
> 
> 
> 
> 
> END ADMIN FORM===
>
> Also if I change the AdminFormVal.php beginning 'if' clause to $_SESSION 
> instead of $_POST, I mysteriously don't get the mysql.sock error. But 
> script does nothing when I do that of course.
> ===
> AdminFormVal.php file looks like this:
>
>  if(isset($_POST['sight']))
> {
> include("connex.php");
> $checkUnameQuery = "SELECT uname FROM admin WHERE uname ='$_POST[uname]'";
> $checkUnameQueryResult = mysql_query($checkUnameQuery) or die("Can't 
> Connect to Admin" . mysql_error());
> $rowResults = mysql_num_rows($checkUnameQueryResult);
>
> if($rowResults == 1) //login name was found
> {
>  $checkUnameQuery = "SELECT uname FROM admin WHERE uname ='$_POST[uname]' 
> AND pword ='$_POST[pword]'";
>  $checkUnameQueryResult2 = mysql_query($checkUnameQuery) or die("Can't 
> Connect to Admin" . mysql_error());
>  $rowResults2 = mysql_num_rows($checkUnameQueryResult2);
>
>  if($rowResults2 > 0) //password was found
>  {
>   $_SESSION['auth'] = "yes";
>   header("Location: Admin.php");
>  }
> }
> else
> {
>  $_SESSION['auth'] = "no";
>  $_SESSION['sight'] = "error";
>  header("Location: AdminForm.php");
> }
> }
> ?>
> === 

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



[PHP] Checking Post Data against DB Data

2007-07-10 Thread kvigor
/*Good Morning to All,

I am having an issue with the following code.  I'm trying to match 
$newRegistrant(which is concatenated form data) with $oldRegistrant(which is 
concatenated DB data).  The code is suppose to check if the Registrants 
match, if they do, then check if last registration was less than 24hrs ago, 
if it is it sets $FLAG to 1
and throws and error at the user.

Problem is the follow code only displays the error message from the 
"//unknown check" section, and not the //central check section.  I know the 
code is virtually identical except for the table it's pulling data from. 
POST data has been mysql escaped. And form is submitted twice w/same info 
and no FLAG/error message*/
//I hope this helps.  Because I NEED HELP :-(



http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
*** SORRY ONLY 1 
REGISTRATION PER 24HRS. ***";
}

else
{
   function trim_value(&$value)
  {
  $value = trim($value);
  }
//==
  $cen_foodlandPA = file('C:\htdocs\website\central_foodlandPA.txt');
  array_walk($cen_foodlandPA, 'trim_value');
  $cen_independents = file('C:\htdocs\website\central_independents.txt');
  array_walk($cen_independents, 'trim_value');
//==

  if(@sizeof($format) == 0 && @sizeof($blank_array) == 0 && @sizeof($curse) 
== 0 && @sizeof($us_states) == 0 && @sizeof($phoneFormat) == 0 && $FLAG == 
2)
  {
   echo "Thank You for Entering. Your Entry has 
been accepted!
   ";
   echo " Click on logo to return to Main 
Page.";
   $greenLightForDBstorage = "go";
   global $greenLightForDBstorage;
  }

  if(isset($_POST['strName'], $_POST['strCity'], $_POST['strState']))
  {
   $tab = " ";
   $storeInfo = 
$_POST['strName'].$tab.$_POST['strCity'].$tab.$_POST['strState'];
   global $storeInfo;
  }

  if(in_array($storeInfo, $cen_foodlandPA))
  //if statement to check all other fields before record is set
  {$queryCentral = "INSERT INTO central (conName, conAddress, conCity, 
conState, conZip, conPhone, schName, schAddress, schCity,
schState, schZip, strName, strCity, strState,varStamp) 
VALUES('$regName', '$regAddress', '$regCity', '$regState', 
'$regZip','$regPhone', '$sclName', '$sclAddress', '$sclCity', '$sclState', 
'$sclZip', '$stoName', '$stoCity', '$stoState','$timeStamp')"
 ;

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

  elseif(in_array($storeInfo, $cen_independents))
  {
   $queryCentral = "INSERT INTO central (conName, conAddress, conCity, 
conState, conZip, conPhone, schName, schAddress, schCity,
schState, schZip, strName, strCity, strState,varStamp) 
VALUES('$regName', '$regAddress', '$regCity', '$regState', '$regZip',
 '$regPhone', '$sclName', '$sclAddress', '$sclCity', '$sclState', 
'$sclZip', '$stoName', '$stoCity', '$stoState','$timeStamp')"
 ;

   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,varStamp) VALUES('$regName', 
'$regAddress', '$regCity', '$regState', '$regZip',
'$regPhone', '$sclName', '$sclAddress', '$sclCity', '$sclState', 
'$sclZip', '$stoName', '$stoCity', '$stoState','$timeStamp')";
mysql_query($queryUnknown, $connection) or die("Query failed: ". 
mysql_error($connection));
  }
 }
}

?> 

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



[PHP] Array Question

2007-07-10 Thread kvigor
Is there a php function similar to in_array that can detect if a "partial 
value" is in an array value or not:

e.g.

$var1 = " big horse";$var2 = " small yellow";$var3 = " red hydrant";

$theArray = array(big blue horse, small yellow bird, giant red hydrant);

Is there a way to find out if $var1 in $theArray or $var2 etc.? 

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



Re: [PHP] Checking Post Data against DB Data

2007-07-11 Thread kvigor
OK Chris,

I understand that we're checking checking the form data and escaping it, but 
can explain what's going on in the WHERE clause and  1=1 tad bit more.


"Chris" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>> /*Good Morning to All,
>>
>> I am having an issue with the following code.  I'm trying to match 
>> $newRegistrant(which is concatenated form data) with $oldRegistrant(which 
>> is concatenated DB data).
>
> First thing I'd suggest is making the code clearer about what's going on.
>
> Doing it the way I have below will also make it faster because you don't 
> have to check every registrant to see if they already there - make the 
> database do the work for you.
>
>
> $newRegistrant_query = "SELECT 
> conName,conAddress,conCity,conState,conPhone,schName,schCity,schState,strName,strCity,strState
> FROM central WHERE ";
> if(isset($_POST['submit'])) {
> $fields_to_check = array('conName', 'conAddress', 'conCity' . add more 
> fields here);
> foreach ($fields_to_check as $field_name) {
> $newRegistrant_query .= $field_name . "='" . 
> mysql_real_escape_string($_POST[$field_name]) . "' AND ";
> }
> // you can either remove the last AND from the query or just add this on 
> so you don't need to worry about a mal-formed query.
> $newRegistrant_query .= "1=1";
> }
>
> Then
>
> $matchQueryResult_result = mysql_query($newRegistrant_query,$connection) 
> or die
> ("Query Failed".mysql_error());
>
> $found_registrant = false;
> while ($row = mysql_fetch_assoc($matchQueryResult_result)) {
> $found_registrant = true;
> // check your datestamps.
> }
>
> // they have never registered before
> if (!$found_registrant) {
>   // make up an insert query and add them.
> }
>
> makes it a lot easier to read and be a lot easier to debug.
>
> -- 
> Postgresql & php tutorials
> http://www.designmagick.com/ 

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



Re: [PHP] Array Question

2007-07-11 Thread kvigor
Thanks,

I've seen the light by your code.

""Robin Vickery"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 11/07/07, kvigor <[EMAIL PROTECTED]> wrote:
>> Is there a php function similar to in_array that can detect if a "partial
>> value" is in an array value or not:
>>
>> e.g.
>>
>> $var1 = " big horse";$var2 = " small yellow";$var3 = " red 
>> hydrant";
>>
>> $theArray = array(big blue horse, small yellow bird, giant red hydrant);
>>
>> Is there a way to find out if $var1 in $theArray or $var2 etc.?
>
> There's not a built in function, but it's not hard to write one:
>
> function partial_in_array($needle, $haystack) {
>  if (!is_array($needle)) { $needle = array($needle); }
>
>  $needle = array_map('preg_quote', $needle);
>
>  foreach ($needle as $pattern) {
>if (count(preg_grep("/$pattern/", $haystack)) > 0) return true;
>  }
>
>  return false;
> } 

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



Re: [PHP] Array Question

2007-07-17 Thread kvigor
Thanks for all the input.  You've all been pretty informative.  Sorry of 
delayed response to help but was busy.  You all are appreciated.


"Stut" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Richard Lynch wrote:
>> On Wed, July 11, 2007 4:16 pm, Robert Cummings wrote:
 But I'd have to say that the intent is not all that clear, really,
 and
 I'd be leery of this feature, personally.
>>> I wouldn't be leery at all. It's been around for a very long time and
>>> it's documented:
>>>
>>>
>>> http://www.php.net/manual/en/language.types.array.php#language.types.array.casting
>>
>> As soon as I hit send I knew that would be mis-interpreted...
>>
>> Leery is the wrong word.
>>
>> Sorry.
>>
>> It just seems a bit to clever to me...
>>
>> I suspect I'd skim this code a hundred times and not realize what it
>> was doing.
>>
>> But maybe that's just me. :-)
>
> I would have to agree. I'm a big fan of self-documenting code, and this 
> one requires a little bit more knowledge of the intricacies of PHP than I 
> would expect from your 'average' developer.
>
> If performance is going to be an issue (and in terms of cycles I can't see 
> this saving much), buy faster/more hardware - it's far cheaper than 
> developer time!!
>
> -Stut
>
> -- 
> http://stut.net/ 

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



Re: [PHP] Checking Post Data against DB Data

2007-07-17 Thread kvigor
I really like the re-coding it's great.  I'm still new and below code is 
definitely more efficient.

FYI: I do have date field sorry I wasn't so clear.  I just didn't post all 
code.

""Richard Lynch"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Doing a select to get every record, and then looping through them all,
> concatenating a bunch of stuff together, and then using PHP to test ==
> is not very efficient...
>
> Why not just:
>
> $sql = array_map('mysql_real_insert_string', $POST);
> $query = " select count(*) from central ";
> $query .= " where conName = $sql[conName] ";
> $query .= "   and conAddress = $sql[conAddress] ";
> .
> .
> .
> $query .= "   and SOME_DATETIME_FIELD_WHEN_THEY_REGISTERED >=
> date_sub(now(), interval 1 day) ";
>
> Also note that your are currently comparing the $_POST['timeStamp']
> which is *probably* generated at the time the HTML form was sent with
> time(); which is when the script is processing, which will be MUCH
> less than one day, unless a user opens up the form, walks away for 24
> hours, and then comes back to complete registration...
>
> You need a field in the database from previous registration to compare
> to time().

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



Re: [PHP] Selecting Rows Based on Row Values Being in Array

2007-07-17 Thread kvigor
This is working so far but I need to add an additional search.

This is what I have so far:

$in_list = "'".join("','",$cen_chiefs)."'";

$query_cen_chiefs = "SELECT * FROM central WHERE CONCAT(strName,' 
',strCity,' ',strState) IN({$in_list}) ORDER BY conName";

I also need the query to return records where strName values are in 
$cen_chiefs

I tried query 5 different ways and none return any records except for one 
above.
This is one that failed:

"SELECT * FROM central WHERE CONCAT(strName,' ',strCity,' ',strState) 
IN({$in_list}) AND WHERE (strName) IN({$in_list}) ORDER BY conName";

Any suggestions?


"Jim Lucas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> K. Hayes wrote:
>> Will do.  Thanks.
>>
>>
>> - Original Message - From: "Jim Lucas" <[EMAIL PROTECTED]>
>> To: "kvigor" <[EMAIL PROTECTED]>
>> Cc: 
>> Sent: Saturday, June 30, 2007 1:46 AM
>> Subject: Re: [PHP] Selecting Rows Based on Row Values Being in Array
>>
>>
>>> kvigor wrote:
>>>> Hello All,
>>>>
>>>> I'm attempting to return rows from a mysql DB based on this criteria:
>>>>
>>>> I have a list, in the form of an array that I need to compare against 
>>>> each row
>>>> in the table.  Where theres a match I need that entire row returned.
>>>>
>>>> e.g.$varListof 3outOf_10Fields = array(6blue40lbs, 7orange50lbs, 
>>>> 8orange60lbs, 9purple70lbs);
>>>>
>>>> The array contains 3 of the db row fields in 1 value. However there are 
>>>> 10 fields/columns in the table.
>>>>
>>>> ===
>>>> what table looks like  |
>>>> ===
>>>>   size   colorweight
>>>> ROW 1| value1 | value1 | value1 | value1 | value1 | value1 |
>>>>
>>>> So how could I set up a query that would SELECT the entire row, if the 
>>>> row contained $varListof 3outOf_10Fields[1].
>>>>
>>>> Open to any suggestions or work arounds.  I'm playing with extract() 
>>>> but code is too crude to even post.
>>>>
>>> I would suggest approaching the problem with a slightly different 
>>> thought.
>>>
>>> just have the sql concat() the columns together and then compare.
>>>
>>> something like this should do the trick
>>>
>>> $list = array(
>>> '6blue40lbs',
>>> '7orange50lbs',
>>> '8orange60lbs',
>>> '9purple70lbs',
>>> );
>>>
>>> $SQL = "
>>> SELECT *
>>> FROM my_Table
>>> WHERE CONCAT(value1, value2, value3) IN ('".join("','", $list)."')
>>> ";
>>>
>>> mysql_query($SQL);
>>>
>>> this should take, for each row in the DB, value1 + value2 + value3 and 
>>> create one string from them, then it will compare each string in the
>>> IN (...)  portion to each entry in the $list array().
>>>
>>> Let me know if you need any further help
> one other thing, make sure that you run each of the values in the $list 
> array() through mysql_real_escape_string().  That way it is all nicely 
> encoded for the SQL statement. 

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



Re: [PHP] Selecting Rows Based on Row Values Being in Array

2007-07-17 Thread kvigor
Hello Master Coders,



This is working so far but I need to add an additional search.



This is what I have so far:



$in_list = "'".join("','",$cen_chiefs)."'";



$query_cen_chiefs = "SELECT * FROM central WHERE CONCAT(strName,'

',strCity,' ',strState) IN({$in_list}) ORDER BY conName";



I also need the query to return records where strName values are in

$cen_chiefs



I tried query 5 different ways and none return any records except for one

above.

This is one that failed:



"SELECT * FROM central WHERE CONCAT(strName,' ',strCity,' ',strState)

IN({$in_list}) AND WHERE (strName) IN({$in_list}) ORDER BY conName";



Any suggestions?


"Jim Lucas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>> Hello All,
>>
>> I'm attempting to return rows from a mysql DB based on this criteria:
>>
>> I have a list, in the form of an array that I need to compare against 
>> each row
>> in the table.  Where theres a match I need that entire row returned.
>>
>> e.g.$varListof 3outOf_10Fields = array(6blue40lbs, 7orange50lbs, 
>> 8orange60lbs, 9purple70lbs);
>>
>> The array contains 3 of the db row fields in 1 value. However there are 
>> 10 fields/columns in the table.
>>
>> ===
>> what table looks like  |
>> ===
>>   size   colorweight
>> ROW 1| value1 | value1 | value1 | value1 | value1 | value1 |
>>
>> So how could I set up a query that would SELECT the entire row, if the 
>> row contained $varListof 3outOf_10Fields[1].
>>
>> Open to any suggestions or work arounds.  I'm playing with extract() but 
>> code is too crude to even post.
>>
> I would suggest approaching the problem with a slightly different thought.
>
> just have the sql concat() the columns together and then compare.
>
> something like this should do the trick
>
> $list = array(
> '6blue40lbs',
> '7orange50lbs',
> '8orange60lbs',
> '9purple70lbs',
> );
>
> $SQL = "
> SELECT *
> FROM my_Table
> WHERE CONCAT(value1, value2, value3) IN ('".join("','", $list)."')
> ";
>
> mysql_query($SQL);
>
> this should take, for each row in the DB, value1 + value2 + value3 and 
> create one string from them, then it will compare each string in the
> IN (...)  portion to each entry in the $list array().
>
> Let me know if you need any further help 

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



[PHP] If MySQL column/field values are in an PHP array

2007-07-19 Thread kvigor
I created an array using the following:

$in_list = "'".join("','",$cen_chiefs)."'"; //$cen_chiefs is an array

$query_cen_chiefs = "SELECT * FROM central WHERE CONCAT(strName,' 
',strCity,' ',strState) IN({$in_list})";

How would I go about adding an AND clause to the above query to return all 
rows where strName column values are in $in_list array

I acutally did the above w/ "SELECT * FROM central WHERE CONCAT(strName,' 
',strCity,' ',strState)
IN({$in_list}) AND (strName) IN({$in_list}) ORDER BY conName"; // This 
return zero rows.

I think I Should I be using strName as a pattern, because strName would be a 
partial value of $in_list array values?

Something like: REGEXP '^.$'

"SELECT * FROM central WHERE CONCAT(strName,' ',strCity,' ',strState) 
IN({$in_list}) AND (REGEXP '^strName$') IN({$in_list}) ORDER BY conName"; 
//This query doesn't work by the way.  This is where I'm stuck. 

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



[PHP] Re: If MySQL column/field values are in an PHP array

2007-07-19 Thread kvigor
OK,

$cen_fields is an array of a store's Name, City, and State concatenated.

$cen_fields[0] echo'd looks like this: CHIEFS SUPERMARKET ST. MARYS OH 
$cen_fields[1] echo'd looks like this: CHIEFS SUPERMARKET CELINA OH

$in_list is the concatenated store's Name, City, and State but formatted w/ 
commas for MySQL.

i.e.
>From > $in_list = "'".join("','",$cen_chiefs)."'";

$in_list echo'd looks like this:

'CHIEFS SUPERMARKET ST. MARYS OH','CHIEFS SUPERMARKET CELINA OH','CHIEFS 
SUPERMARKET COLDWATER OH','CHIEFS SUPERMARKET DELPHOS OH','CHIEFS 
SUPERMARKET DEFIANCE OH','CHIEFS SUPERMARKET BRYAN OH','CHIEFS SUPERMARKET 
WAUSEON OH','CHIEFS SUPERMARKET PAULDING OH','CHIEFS SUPERMARKET NAPOLEON 
OH'


The central table looks like the following: (There's more columns but to be 
concise I added ones in question)

++-+--+
| strName| strCity | 
strState |
++--+--+
| VILLAGE STORE 14 FRESH | WEST PENESIO  | PA   |
| VILLAGE STORE 19 FRESH | WEST PENESIO  | PA   |
| CHIEFS SUPERMARKET  | ST. MARYS | OH   |
++---++

So user fills in form.  Table is populated with form data, and if the store 
name, city, and state matches exactly to $in_list value it'll store form 
data in this particular table.

With my current query, rows will be returned only if they match strName, 
strCity, strState exactly.

In addition to that I want the query to return the rows where strName 
matches partial $in_list array value

So if CHIEFS SUPERMARKET ST. MARYS OH is a value in $in_list If user only 
enters "CHIEFS" and not CHIEFS SUPERMARKET I want to be able to return that 
row also, even though it doesn't exactly match array value.

I hope this is more clear.  I tried the MySQL forums but they are kinda slow 
responding.

//
""M. Sokolewicz"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> kvigor wrote:
>> I created an array using the following:
>>
>> $in_list = "'".join("','",$cen_chiefs)."'"; //$cen_chiefs is an array
>>
>> $query_cen_chiefs = "SELECT * FROM central WHERE CONCAT(strName,' 
>> ',strCity,' ',strState) IN({$in_list})";
>>
>> How would I go about adding an AND clause to the above query to return 
>> all rows where strName column values are in $in_list array
>>
>> I acutally did the above w/ "SELECT * FROM central WHERE CONCAT(strName,' 
>> ',strCity,' ',strState)
>> IN({$in_list}) AND (strName) IN({$in_list}) ORDER BY conName"; // This 
>> return zero rows.
>>
>> I think I Should I be using strName as a pattern, because strName would 
>> be a partial value of $in_list array values?
>>
>> Something like: REGEXP '^.$'
>>
>> "SELECT * FROM central WHERE CONCAT(strName,' ',strCity,' ',strState) 
>> IN({$in_list}) AND (REGEXP '^strName$') IN({$in_list}) ORDER BY conName"; 
>> //This query doesn't work by the way.  This is where I'm stuck.
>
> First of all, let's start by saying that this question is very OT on a 
> php-list. It would be a lot more appropriate on a mysql list. But, I'll 
> try to help you anyway. First of all, I have no clue what you're trying to 
> do. Give some values (ie. what's in $cen_chiefs, what does the central 
> table look like, and what does strName look like.
>
> The whole problem here, afaics, is that you don't have a clear idea of 
> what you want. Tell us what you _want_ to do (not HOW, but what the result 
> should be) and we might be able to help.
>
> Now,
> SELECT * FROM central WHERE CONCAT(strName,' ',strCity,' ',strState) 
> IN({$in_list}) AND (REGEXP '^strName$') IN({$in_list}) ORDER BY conName
> won't work simply because you're saying (php-style): if($foo == $a.' '.$b 
> && $foo == $a), which obviously will _never_ work :) 

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



[PHP] magic quotes

2007-07-31 Thread KVIGOR
If magic quotes is on and I dont have access to the php.ini.

Is there any way I can strip quotes from the form field with out using AJAX? 

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



[PHP] Re: magic quotes

2007-07-31 Thread KVIGOR
Never Mind I figured it out.

""KVIGOR"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> If magic quotes is on and I dont have access to the php.ini.
>
> Is there any way I can strip quotes from the form field with out using 
> AJAX? 

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