[PHP-DB] Re: سلام دوست من

2015-06-23 Thread Jim Giner

On 6/2/2015 2:17 PM, Mahsa Ehsani wrote:

زمان ثمردهي‌اش گذشته بود و دوره بازنشستگي را طي مي‌كرد. روزگاري طراوت و سرسبزي 
داشت و كودك و بزرگ از قِبَلِ او مرزوق بودند. اما اكنون تمام دلخوشي‌اش اين بود 
كه پيامبر اعظم ـ صلي­الله­عليه­و­آله ـ چون به ايراد سخن مي‌ايستاد بر او تكيه 
مي‌كرد و اين براي او از هر افتخاري بالاتر بود.
نخل خشكيده‌اي در شهر مدينه كه توفيق هم­جواري با حجّت كبراي حق و برترين مخلوق در 
عرصه هستي را پيدا كرده بود.
او چوب خشكيده‌اي بود از جنس نخل، نه ادعاي عقلانيّت داشت و نه خود را در حد و 
اندازه ما انسان‌ها مي‌دانست. اما تمام سرمايه‌اش عشقي بود كه به وجود نوراني 
پيامبر خدا ـ صلي­الله­عليه­و­آله ـ در دل پيدا كرده بود.
چند صباحي گذشت تا اين كه اصحاب براي حضرت منبري سه پله از چوب درست كردند و با 
اجازه ايشان وارد مسجد نمودند، اما تكيه حضرت همچنان به نخل خشكيده بود.
در اثناء سخن، حضرت به سمت منبر حركت كرد. اما چند قدم دورتر نشده بود كه نخل 
صدايش به ناله بلند شد. ناله‌اي از سوز دل مثل ناله ماده­شتر در فراق فرزندش. و 
همه مردم شنيدند و به ستون حنّانه خيره ماندند كه الله اكبر!
الله اكبر از اين شور و اشتياق و از اين بي‌تحملي درد فراق!
اما او نبيّ رحمت بود و كشتي نجات امّت؛ و با همه هستي رفيق شفيق بود و يار صميمي. 
و الله اكبر از اين قلب آكنده از محبّت نبي حتي نسبت به آنچه كه ما بي‌جانش 
مي‌پنداريم.
او برگشت به سوي ستون و با تمام وجود او را در آغوش گرفت و خوشا به حال ستون عاشق. 
نخل اما صداي ناله‌اش عوض شد و مثل كودكي كه بعد از دوري به آغوش مادر رسيده باشد 
هق هق گريست.
و رسول او را نوازش كرد. آن قدر كه نخل در آغوش پرمهر مادر هستي آرام گرفت و 
گريه‌اش خاموش شد.
حضرت رو كرد به مردم و فرمود: به خدا قسم اگر در آغوشش نمي­گرفتم تا قيام قيامت 
ناله‌اش پاياني نداشت!
و مرحبا بر ستون و هزار آفرين بر اين همه ارادت و استقامت!
آري مهدي‌جان! او كه چوب بود و بي‌جان، فراق حجت خدا را چند ثانيه بيشتر نتوانست 
تحمل كند اما ما كه انسانيم و ادعا داريم سيزده قرن فراق تو را ديده‌ايم و هنوز 
صدايمان به ناله بلند نشده است! كه اگر شده بود تو آمده بودي! چرا كه تو پسر همان 
پيغمبري با همه شئونات حتي مهرباني‌اش منهاي وحي.
آري، مشكل از ما است كه لذت با تو بودن را نچشيديم تا در رنج و درد جانسوز فراقت 
ناله زنيم.
ما بيشتر به نبودنت انس گرفته‌ايم تا به بودنت؛ پس بيا، بيا و لذت با ولي بودن و 
با ولي زيستن را به انسانيت بچشان.
هرگونه پخش و نشر اين محتوا بلامانع مي باشد


Uhh,  translation please?

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



[PHP-DB] Re: Input Mathematical symbol in HTML textbox

2015-05-07 Thread Jim Giner

Use the  tag?

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



[PHP-DB] Re: PHP 7 and sqlsrv

2015-04-10 Thread Jim Giner

On 4/10/2015 4:03 PM, John Hermsen wrote:

I was wondering if there is anyone who manager to compile the sqlsrv driver
for php 7.
I have tried, but I haven't been able to get it compiled yet.

Thanks,
John


php 7?? I didn't even see php 6 go past me!

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



Re: [PHP-DB] Waiting for localhost

2015-03-16 Thread Jim Giner

On 3/16/2015 12:02 AM, Ethan Rosenberg wrote:

I have this in the program  --


echo "";
echo "";
echo "";

I'm testing from a form, which previously worked perfectly -

TIA

Ethan



How does your script properly (note: 'properly') recognize that the user 
clicked on the 'Weigh' button?  You don't have a name attribute on that 
submit element so you can't possibly check it.  Consequently users could 
spoof your form to achieve something that you aren't planning on if 
that's any concern to you.


PS - html does not use nor require spaces in its syntax.  Your 
attributes are better written as: method='POST' than the way you are 
doing it.

clicked on the 11


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



[PHP-DB] Re: Error fetching a second row from a result set (mysql)

2014-11-14 Thread Jim Giner

On 11/14/2014 1:46 PM, Mark Murphy wrote:


Problem is that for the resource, the type is changed to Unknown by a
different mysql_query within the loop. Any idea what will cause this?


Maybe show us the whole code so we can see what you are telling us?

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



[PHP-DB] Re: Writing Problems

2014-08-27 Thread Jim Giner

On 8/26/2014 8:44 PM, Ethan Rosenberg wrote:


ini_set('display_startup_errors', 'on');
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors','1');
error_reporting(1);

No errors.

What is wrong??

What is wrong here is your error reporting code.  This is NOT what I 
gave you two months ago.  You don't read your code, do you?  If you did 
you would see that you do one line to enable error reporting and then 
you do another line to set it differently.  Please use this:


 ini_set('display_startup_errors', 'on');
 error_reporting(E_ALL | E_NOTICE);
 ini_set('display_errors','1');

with the first line only needed if YOU are STARTING UP your php install 
(which if you run on a host somewhere you are not doing).  From THE 
MANUAL (which I take it you never read) your error reporting is set to 
only show fatal errors and not ordinary compile errors or warnings.


Other possible errors in your code:
1 - once again you just blissfully code along and don't bother to 
include error checking to ensure that your query actually ran.  Add a 
test of $result3 to ensure it is not false.
2 - Your query statement uses $upc in the where clause.  If that is not 
a purely numeric value you should be wrapping it in quotes.



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



Re: [PHP-DB] Re: www-data file

2014-08-26 Thread Jim Giner

On 8/26/2014 11:26 AM, Matt Pelmear wrote:


fopen() can create files if they don't exist.

I should have read the manual b4 replying.  :(

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



[PHP-DB] Re: www-data file

2014-08-26 Thread Jim Giner

On 8/26/2014 12:20 AM, Ethan Rosenberg wrote:

Dear list -

When I use  fopen, the  file owner and group are both www-data.

How can I ensure that the owner and group will be ethan?

TIA

Ethan


Why should ownership be a concern when you are simply opening a file? 
AFAIK permissions are set at the time the file is placed there and will 
affect the access to them from then on.  If you are able to fopen the 
file, why do the permissions matter?  If you can't then you have an 
entirely different problem to discuss.


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



Re: [PHP-DB] Query does not work

2014-07-02 Thread Jim Giner
Once again you have provided the group with RANDOM pieces of code, 
completely out of context since you have already shown me that your 
query and db connection are being used in a function, hence your loss of 
$cxn.


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



[PHP-DB] Re: Query does not work

2014-07-01 Thread Jim Giner
Ethan - is error checking turned on as I showed you how to do EXACTLY 
last time you posted


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



Re: [PHP-DB] Re: Query does not work

2014-07-01 Thread Jim Giner

On 7/1/2014 10:26 AM, Aziz Saleh wrote:

On Tue, Jul 1, 2014 at 10:02 AM, Jim Giner 
wrote:


How about just showing us the section of code instead of disjoint pieces
that WE cannot be sure are applied correctly?


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



Also the DB structure would help, using sqlfiddle will make things a lot
easier as well for us (lazy me).

The structure is probably not the problem, since he is not getting 
anything from mysqli_error().


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



[PHP-DB] Re: Query does not work

2014-07-01 Thread Jim Giner
How about just showing us the section of code instead of disjoint pieces 
that WE cannot be sure are applied correctly?


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



Re: [PHP-DB] Re: What is my Mistake?

2014-06-24 Thread Jim Giner
Looking at your code again, I think that your query failed and your lack 
of error reporting isn't showing the error that occurred when  you tried 
to access a property of the result which is not a resource but merely a 
value of 'false'.


One should ALWAYS check the result of operations before assuming that 
they succeeded and proceeding onwards in code.  Saves lots of lost time.


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



Re: [PHP-DB] Re: What is my Mistake?

2014-06-24 Thread Jim Giner

I don't recognize your error reporting configuration.  Try this instead:

error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors','1');


As for php startup errors, if you are not running your own installation, 
you don't need that.


So - if 'here3' is never echoed, then your code does NOT stop there - it 
obviously stopped somewhere prior to that.  Add more debugging lines to 
isolate exactly how far it gets.


(I assume that all of your other echos did appear?)

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



[PHP-DB] Re: What is my Mistake?

2014-06-24 Thread Jim Giner

Ethan -
You say your script stops here :  echo 'here3';  To be sure, you mean 
that the script DOES echo out 'here3' or does NOT get there?  I'm going 
to guess that it does get to that echo statement but the very next one 
is going to kill you because you cannot echo out a resource.


ONCE AGAIN - do you have php error checking turned on as you've been 
told many many times?


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



Re: [PHP-DB] Newbie Question $2

2014-06-18 Thread Jim Giner

On 6/18/2014 2:16 PM, Aziz Saleh wrote:

On Wed, Jun 18, 2014 at 2:13 PM, Karl DeSaulniers 
wrote:




Sent from losPhone


On Jun 18, 2014, at 7:56 AM, Jim Giner 

wrote:



On 6/18/2014 12:31 AM, Ethan Rosenberg, PhD wrote:

On 06/17/2014 12:02 PM, onatawah...@yahoo.ca wrote:
Hi Ethan,

Here are some things to clean up your code:

Your line:

$phn = $_POST[phone];

should use quotations as follows:

$phn = $_POST['phone'];

Your line:

$sql1 ='select Lname, Fname from Customers where Phone = $Phn ';

Should use double quotes if you need the variable to be interpreted:

$sql1 ="select Lname, Fname from Customers where Phone = $Phn ";

Lastly, as people have mentioned PDO is probably the best way to go.
Try connecting to your database with PDO. Look on Google for "PDO
prepared statements" and use those instead of the mysql escape string
method.

Hope this helps,

-Kevin

Sent from Yahoo Mail on Android

IT WORKS!!!

Here is the code -

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



 
 
 
 
 
 
 
 
 
 

$phn[0].$phn[1].$phn[2].$dsh.$phn[3].$phn[4].$phn[5].$dsh.$phn[6].$phn[7].$phn[8].$phn[9];


 $sql1 ="select Lname, Fname from Customers where Phone =
'$Phn' ";
 $result1 = mysqli_query($cxn, $sql1);
 if(!$result)
 {
?>
 

 No Match Found
 
 

 
 
 
 Last Name
 First Name
  
   
   
 

   
 >
 


As you [those that replied] accurately noted, the problem was with the
quoting.

I appreciate all your comments, take them seriously and will use the
information contained in them for future programming.

No matter how much skill in programming I have, I will remain a NEWBIE;
ie, someone who wishes to grrow in knowledge and acknowledges that there
are many programmers much more skilled than I.

Thanks again.

Ethan

happy to hear you got it working.  Sad to see that you didn't heed the

tips provided to you and alter your code, and that you still have errors in
it.  oh, well




Wow. Just wow. I though when I signed up on this list that if I did what
Ethan did I would be shunned from the list. But I guess I was wrong. You
can be an ask hole on here and people will still try and help. Kudos to the
good souls who try.

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



There are lots of people who have free time on their hands to teach the
basics, which I think is a good thing. Personally, if someone doesn't care
enough to read the manual or attempt to understand the basics, I wouldn't
spend too much time on their problems.

And despite Ethan's continual ignorance of the manual and the basic 
principles espoused by those taking the time to respond to him we still 
do it.  Aren't we all amazing?


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



Re: [PHP-DB] Newbie Question $2

2014-06-18 Thread Jim Giner

On 6/18/2014 12:31 AM, Ethan Rosenberg, PhD wrote:

On 06/17/2014 12:02 PM, onatawah...@yahoo.ca wrote:

Hi Ethan,

Here are some things to clean up your code:

Your line:

$phn = $_POST[phone];

should use quotations as follows:

$phn = $_POST['phone'];

Your line:

$sql1 ='select Lname, Fname from Customers where Phone = $Phn ';

Should use double quotes if you need the variable to be interpreted:

$sql1 ="select Lname, Fname from Customers where Phone = $Phn ";

Lastly, as people have mentioned PDO is probably the best way to go.
Try connecting to your database with PDO. Look on Google for "PDO
prepared statements" and use those instead of the mysql escape string
method.

Hope this helps,

-Kevin

Sent from Yahoo Mail on Android



IT WORKS!!!

Here is the code -

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



 
 
 
 
 
 
 
 
 
 

 

 No Match Found
 
 

 
 
 
 Last Name
 First Name
  
   
   
 

   
 >
 


As you [those that replied] accurately noted, the problem was with the
quoting.

I appreciate all your comments, take them seriously and will use the
information contained in them for future programming.

No matter how much skill in programming I have, I will remain a NEWBIE;
ie, someone who wishes to grrow in knowledge and acknowledges that there
are many programmers much more skilled than I.

Thanks again.

Ethan

happy to hear you got it working.  Sad to see that you didn't heed the 
tips provided to you and alter your code, and that you still have errors 
in it.  oh, well


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



Re: [PHP-DB] Re: Newbie Question $2

2014-06-17 Thread Jim Giner

On 6/17/2014 10:51 AM, Lester Caine wrote:

On 17/06/14 15:04, Jim Giner wrote:

We're all so eager to help out poor Ethan (who many of you know is NOT a
newbie) but nowhere does Ethan say what difficulty he is having.

The suggestions made so far are great but what are we solving?

I see you have spotted the original question :)
The original post was fairly complete in what it was asking, and the
answers reasonably worded ...

Yeah - I just didn't take Ethan's comment as 'his question' since a) it 
didn't even have a ? mark on it and b) his spelling of his phn vars was 
crisscrossed re: the usage in the query statement.  I knew people were 
seeing something I wasn't - just didn't realize that the question itself 
was a puzzle of sorts.


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



[PHP-DB] Re: Newbie Question $2

2014-06-17 Thread Jim Giner

Finally figured out what the question was!

Here's a better version of your code Ethan:

$phn = $_POST['phone']; // note the quotes on the index
if (strlen($phn) <> 10)
{
echo "Error in phone number entry - must be 10 digits";
exit();
}
$phn = mysqli_real_escape_string($cxn,$phn);
$masked_phone = substr($phn,0,3) . "-".substr($phn,3,3). "-". 
substr($phn,6,4);
$sql1 = "select Lname, Fname from Customers where Phone = 
'$masked_phone'";	// note use of diff quotes

$result1 = mysqli_query($cxn, $sql1);
if (mysqli_num_rows($result1) == 0)
{
echo "Phone number $masked_phone not on file";
exit();
}
else
{
	echo "Found {$result1['Fname']} {$result1['Lname']} is on file with 
number $masked_phone";

exit();
}


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



[PHP-DB] Re: Newbie Question $2

2014-06-17 Thread Jim Giner
We're all so eager to help out poor Ethan (who many of you know is NOT a 
newbie) but nowhere does Ethan say what difficulty he is having.


The suggestions made so far are great but what are we solving?

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



[PHP-DB] Re: What Does God Look For In Our Heart?

2014-06-05 Thread Jim Giner
Really?  Do we go around proselytizing about our particular concerns , 
broadcast them to you when you are doing something completely unrelated? 
 Do you have no sense of propriety?  How about the maxim of keeping 
your religion to yourself and let others keep theirs?


Religious zealots (as apparently are you) are much of the problem with 
the world today.  Now I have to listen to it while trying to escape into 
the php world?


There's a time and place for everything.  This is not the place for your 
sermons.


Please get ahold of your emotions and stop pestering people with this stuff.

On 4/26/2014 8:56 PM, Ken MD wrote:

What Does God look for in our heart?



How does God give everyone from the beginning of time an equal opportunity to be
saved?

The scriptures teach us God wants everyone to be saved ( 1 Tim 2:4
 ), and that he is Just (
Deuteronomy 32:4
 ); and shows no favoritism ( Romans
2:11
 ).

Because God is Just and shows no favoritism He does not give anyone an advantage
over another when it comes to salvation.  Those born in a Godly home have no
more of an advantage to be saved than someone born in a remote part of the world
who has never heard the gospel.  Those born after Jesus death have no more of an
advantage to be saved than someone born before his death.

How does God give everyone an equal opportunity to be saved?  The answer lies in
the innermost part of our being ( Psalm 51:6
 )!

God enlightens everyone that comes into the world ( John 1:9
 ), He draws us to him first because we are
not able to come to him on our own ( John 6:44
 ).  If we accept his invitation he leads us
to salvation ( John 16:13

 )!

What does God look for in our heart?

A wonderful example may be found with one of the two criminals who died with
Jesus on the cross. One criminal was invited to Paradise ( Luke 23:43
 ) the other was not.  Why such different
outcomes?

Both criminals hurled abuse towards Jesus ( Mark 15:32
 ), but one of them began to acknowledge him
as the Christ, pleading with Jesus to save himself and him!  Jesus saw the
motive of his heart and did not respond.

The other criminal who also hurled abuse towards Jesus began to reveal a
different motive so Jesus invited him to Paradise!

Let’s take a closer look at what God uncovered in the heart of these two
criminals.  Their heart is revealed in eight statements; two by the criminal who
did not receive an invitation to Paradise and six by the criminal who was
invited ( Luke 23:39-43
 ).

We should note the scriptures are clear man’s heart is deceitful and
desperately wicked ( Jeremiah 17:9
 ) but it gives room for desire ( Acts
13:22
 , Luke 18:13
 , Joshua 24:15
 , Matt 13:15
 ).

Statement #1 “Are you not the Christ”?  (Uninvited Criminal)
His reference to Jesus as the Christ is more of a political statement in an
effort to solicit a favor rather than be in awe of who Jesus is.

  Statement #2 “Save yourself and us”.  (Uninvited Criminal)
His earthly life is his primary interest and he doesn’t see the need for Jesus
to die.

Statement #1 “Do you not even fear God”? (Invited criminal)
He begins with the fear of God!  How apropos considering the “Fear of God”
is the beginning of wisdom ( Psalms 111:10
 ).

Statement #2 “Since you are under the same sentence of condemnation”?
(Invited criminal)
He was ashamed when compared to Jesus who was equally being condemned.

Statement #3 “and we indeed are suffering justly” (Invited criminal)
He acknowledged the consequences for his actions.

Statement #4 “for we are receiving what we deserve for our deeds” (Invited
criminal)
He took ownership of what he had done wrong (I am a sinner).

Statement #5 “but this man has done nothing wrong”! (Invited criminal)
He confesses Jesus was innocent ( John 1:29
 )! Symbolizing the Lamb of God.

Statement #6 “Jesus, remember me when you come into your kingdom”! (Invited
criminal)
God’s kingdom is where his will is ( Matt 6:10
 ).  He wanted God’s will over his own!

Notice the similarity of Adam’s heart with the criminal invited to Paradise…

Adam feared God: “I was afraid”( Gen 3:10
 )!

Adam was ashamed: “I was naked”( Gen 3:10
 )!

Adam was aware of consequences: “I hid mys

[PHP-DB] PDO Connection problem

2014-01-10 Thread Jim Giner

History:
I'm trying to help a friend who is hosting his domain with the same 
company that I use.  I've been using this company for several years and 
have used a certain 'connection' script all the time.  Part of it looks 
like this:


$host="mysql:host=mydomain.com;dbname=$sc_dbname;charset=utf8";
$uid = "uid";
$pswd = "pswd";
Try
{
$mysql = new PDO($host,$uid,$pswd,$db_options);
}
.

So - when I tried to provide this template to my friend (who is new to 
all of this) we went thru days of emails trying to make sure everything 
was setup correctly but could never get a connection using the above 
code.  Finally last night, after reviewing how my 'old' mysql interface 
connection worked, I experimented with the above changing my host= from 
my domain name to simply 'localhost'.  Voila - it worked for him.  It 
also worked for my site.


Here's my question:  What would make by friend's account not work when 
referencing a true domain name in the host= attribute?  I'm assuming 
that our (shared) provider is setting up his many accounts & servers the 
same way, but I could be wrong.  And of course, I don't have a clue 
about what makes any of this work - I simply follow 
instructions/guidance I get from manuals and searches until I get things 
to work.  That's how I got his account to finally work, but I'd love to 
have an idea why it now does.



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



[PHP-DB] Re: joints - extracting common results from comparing 2 tables

2013-10-23 Thread Jim Giner

On 10/23/2013 8:15 AM, Taco Mathijs Hillenaar-Meerveld wrote:

Good afternoon,

i haven't done much with php and Mysql the past 2 years so my knowledge is
not really up-to-date.

i'm not a hero when it comes to math. actually, it's a weakness but trying
to fix that.

i made a query where i compare 2 tables against eachother and then i want
to see a table that shows me results: the Relation + Surname should match.

i have chosen for those two because Surname was a required input and all
contacts must have a relation. also, in those tables there are fields that
have completely messed up information that shouldn't be there in the first
place, phone numbers as names f.e..

that aside i made this query:

 $sql = 'SELECT table_a1.Surname, table_a2.Relation, table_a1.City
 FROM table_a1
 INNER JOIN table_a2
 ON table_a1.Relation=table_a2.Relation';w

I get a row back. my question:

is this an appropiate and common way to get this job done? im NOT used to
dig deep in this kind of stuff but i can see in the future i will need a
few handy scripts.

tips and advice are very welcome.

You really don't need the INNER JOIN to do this.  Your task ( to find 
those records that have matching relation values can be done very 
simply.  Replace it all with :


"select a1.Surname, a1.City, a2.Relation
FROM table_a1  a1, table_a2 a2
  where a1.Relation = a2.Relation"

(Note my use of the simpler alias instead of the full table name.)

I realize that this is probably a simplification of your true goal, but 
just in case it is not, I point out that I don't see the value of this 
particular query.  You are looking for matching records but you don't 
pull any information from the matched records that you don't already 
have in the a1 table.  Do I assume that you will be adding more fields 
in your selection?


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



Re: [PHP-DB] Subject Matter

2013-08-23 Thread Jim Giner

On 8/23/2013 4:52 AM, Matt Pelmear wrote:

On 08/23/2013 04:36 PM, Lester Caine wrote:

Matt Pelmear wrote:

I am not sure who runs the list, whether they care about off-topic
posts,
or whether anyone else cares about it.


The php lists are only loosely moderated, but comments like yours
usually bring things under control. I'd refer you to my recent post
thought as to why the current threads are not that far off topic ;)



Indeed, that thread is one that is on topic... but I think the
signal-to-noise ratio on this list is rather poor ;)
If I'm the only one bothered by it, it's no big deal for me to
unsubscribe... I just thought I'd check the general opinion first.
I don't run into these problems on the internals list... :-)

-Matt

Funny - I never knew this list was handling  off-topic posts that 
regularly.  I always thought this list was about using php to access 
database info and the problems incurred, such as Ethan's recent post 
about his bad query code.


So - this is supposed to be about "database integration"?  I'll have to 
reconsider my subscription choice as well, just as soon as I look up 
whatever the heck that is.  :)



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



Re: [PHP-DB] Re: mysql query

2013-08-23 Thread Jim Giner

On 8/23/2013 4:32 AM, Lester Caine wrote:

Karl DeSaulniers wrote:

If your on a PC I would just get Eclipse. But if you have netbeans,
you can set the syntax highlighting for the different scripts you
write in the preferences. PHP, java, javascript, etc...


But the problem tha5 has been identified will never be flagged by simple
highlighting. Debugging complex SQL queries is possibly better done
outside of the PHP pages. Not sure exactly what SQL plug-in I've got
running on Eclipse at the moment, but as Ethan identified earlier, the
SQL script ran from the command line. It was passing the variables into
it which was wrong.

I'm with him on the statement that MySQL should have returned an error.
Certainly Firebird would have done and so identifying the problem might
have been easier.

I think the reason he didn't get the error was cause of his lack of a 
connection which never allowed it to run.


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



Re: [PHP-DB] Re: mysql query

2013-08-23 Thread Jim Giner

On 8/22/2013 8:08 PM, Ethan Rosenberg wrote:


Ethan Rosenberg, PhD
/Pres/CEO/
*Hygeia Biomedical Research, Inc*
2 Cameo Ridge Road
Monsey, NY 10952
T: 845 352-3908
F: 845 352-7566
erosenb...@hygeiabiomedical.com
On 08/22/2013 06:56 PM, Jim Giner wrote:

On 8/22/2013 4:14 PM, Ethan Rosenberg wrote:

On 08/22/2013 11:54 AM, Jim Giner wrote:

On 8/22/2013 9:52 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql> describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = "insert into Inventory (UPC,
quant,
manuf, item, orderpt, ordrpt_flag, stock)"
 ."values ('$upc',
$qnt,'$mnf','$itm',
odrpt, 0, $stk)";
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt
$opf
$stk";
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan




Ethan - you are simply missing two dollar signs as pointed out. Once
you correct them, if there are any more errors you should then be
seeing
the message from mysqli_error.

And as for the advice to dump single quotes, I'd ignore it. The use of
double and single quotes is a very handy feature and makes for very
readable code.  Escaping double quotes is such a royal pia and
makes for
more trouble deciphering code later on.  The sample you provided
for us
is some of the best and most understandable code you've ever showed
us.


Also - Ethan - if you used an editor that was designed for php you
probably would have seen these missing $ signs since a good one would
highlight php syntax and the lack of the $ would have produced a
different color than you expected.


Jim -

I  used Netbeans.  All it said is "variable unused is scope", which is
a  error that I often find does not mean anything.  I am as pressurized
as you are.  Any suggestions as to an editor?

Ethan



Did you mean to say "unused IN scope"?  That would be telling you that
it is not yet defined and that could be a problem if you expect to be
already defined.

Several other posts here have listed their favorites.  Notepad ++
seems to be a favorite.  I use HTML-kit Tools as my developing
environment. Handles highlighting for php, html and js, as well as
project organization.  Also includes an ftp engine to allow me to
modify, upload and then go test my code very quickly. (I don't run php
or apache locally.)

Jim -

Thanks.

unused IN scope - correct.

There are lots of editors mentioned in this email trail.  I thank all
for the suggestions.

Netbeans, Aptana Studio, etc will all highlight code and show the errors
the code would generate in a browse. The problem here was two missing $
signs.

I'm probably wrong, but in some contexts; eg, sql query, $ signs are not
used.  I tried and added the incorrect $ sign, and Netbeans did not
complain.  If anyone knows of an editor that will able to spot this kind
of error, please inform the list.

Ethan

Wrong in one sense - all php vars must have a $ sign.  When building a 
query statemtent, if the editor doesn't tell you something (by not 
colorizing it) Sql is going to tell you when you attempt to run it. 
That's why one should ALWAYS include an error check after any operation.


BTW - this line
echo '$sql2';

isn't going to give you what you want.

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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Jim Giner

On 8/22/2013 4:14 PM, Ethan Rosenberg wrote:

On 08/22/2013 11:54 AM, Jim Giner wrote:

On 8/22/2013 9:52 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql> describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = "insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)"
 ."values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk)";
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt $opf
$stk";
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan




Ethan - you are simply missing two dollar signs as pointed out. Once
you correct them, if there are any more errors you should then be seeing
the message from mysqli_error.

And as for the advice to dump single quotes, I'd ignore it.  The use of
double and single quotes is a very handy feature and makes for very
readable code.  Escaping double quotes is such a royal pia and makes for
more trouble deciphering code later on.  The sample you provided for us
is some of the best and most understandable code you've ever showed us.


Also - Ethan - if you used an editor that was designed for php you
probably would have seen these missing $ signs since a good one would
highlight php syntax and the lack of the $ would have produced a
different color than you expected.


Jim -

I  used Netbeans.  All it said is "variable unused is scope", which is
a  error that I often find does not mean anything.  I am as pressurized
as you are.  Any suggestions as to an editor?

Ethan


Did you mean to say "unused IN scope"?  That would be telling you that 
it is not yet defined and that could be a problem if you expect to be 
already defined.


Several other posts here have listed their favorites.  Notepad ++ seems 
to be a favorite.  I use HTML-kit Tools as my developing environment. 
Handles highlighting for php, html and js, as well as project 
organization.  Also includes an ftp engine to allow me to modify, upload 
and then go test my code very quickly. (I don't run php or apache locally.)


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



[PHP-DB] Re: mysql query

2013-08-22 Thread Jim Giner

On 8/22/2013 9:52 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql> describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = "insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)"
 ."values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk)";
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt $opf
$stk";
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan




Ethan - you are simply missing two dollar signs as pointed out.  Once
you correct them, if there are any more errors you should then be seeing
the message from mysqli_error.

And as for the advice to dump single quotes, I'd ignore it.  The use of
double and single quotes is a very handy feature and makes for very
readable code.  Escaping double quotes is such a royal pia and makes for
more trouble deciphering code later on.  The sample you provided for us
is some of the best and most understandable code you've ever showed us.

Also - Ethan - if you used an editor that was designed for php you 
probably would have seen these missing $ signs since a good one would 
highlight php syntax and the lack of the $ would have produced a 
different color than you expected.


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



[PHP-DB] Re: mysql query

2013-08-22 Thread Jim Giner

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql> describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = "insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)"
 ."values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk)";
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt $opf
$stk";
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan



Ethan - you are simply missing two dollar signs as pointed out.  Once 
you correct them, if there are any more errors you should then be seeing 
the message from mysqli_error.


And as for the advice to dump single quotes, I'd ignore it.  The use of 
double and single quotes is a very handy feature and makes for very 
readable code.  Escaping double quotes is such a royal pia and makes for 
more trouble deciphering code later on.  The sample you provided for us 
is some of the best and most understandable code you've ever showed us.



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



[PHP-DB] Re: mysql query

2013-08-22 Thread Jim Giner

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql> describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = "insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)"
 ."values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk)";
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2';
   print_r($sql2);
   echo "$upc $qnt $mnf $itm $odrpt $opf
$stk";
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan



Ethan - you are simply missing two dollar signs as pointed out.  Once 
you correct them, if there are any more errors you should then be seeing 
the message from mysqli_error.


And as for the advice to dump single quotes, I'd ignore it.  The use of 
double and single quotes is a very handy feature and makes for very 
readable code.  Escaping double quotes is such a royal pia and makes for 
more trouble deciphering code later on.  The sample you provided for us 
is some of the best and most understandable code you've ever showed us.



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



[PHP-DB] Re: One query, different tables?

2013-08-09 Thread Jim Giner

On 8/9/2013 10:56 AM, Karl-Arne Gjersøyen wrote:

Hello.
I am newbie in this and need som basic help.

I have a form witch checkbox'es with different serialnumbers.
The serialnumbers reflect different products and every product category
have their own tables.

I can transfer items from store to truck but can't transfer them back to
store.
I have 4 stores and like to transfer products between this.

I like to to it like this:
store_one -> truck_document -> store_two

But how can I transfer both Dynamite and Exan in one query to their
respective tables? (One table is named exan and the other dynamite.)

Thank you very much for your help.

I have been searching google but can't find anything about this question.

Karl

This makes no sense.  How are we supposed to help you with just this to 
go on?


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



[PHP-DB] Re: Mysql PDO statement with params in HAVING problem

2013-06-27 Thread Jim Giner

On 6/27/2013 7:51 AM, Alexander Pletnev wrote:

Hi everyone, im new here, so please correct me if i created or formated
topic incorrectly.

I found a problem. I have a simple query for my needs:

 $stmt = $dbh->prepare("SELECT concat(first_name,' ',last_name) as
 full_name,t.* FROM `specialists` `t` HAVING full_name like '%john%'");
 $stmt->execute();
 while($row = $stmt->fetch())
 {
echo ''; var_dump($row); echo '';
 }

It works fine, until i add a param to my query:

 $stmt = $dbh->prepare("SELECT concat(first_name,' ',last_name) as
 full_name,t.* FROM `specialists` `t` HAVING full_name like '%:query%'");
 $stmt->execute();
 $query = 'londo';
 $stmt->bindParam(':query',$query);
 while($row = $stmt->fetch())
 {
echo ''; var_dump($row); echo '';
 }

Now there is nothing in fetch(). Is it a bug ?

Thanks.


First - you prepare the query
Second - you create and 'bind' the parameters to it
Third - you execute the now completed query
Fourth - you process the results.

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



Re: [PHP-DB] Re: Problem with query

2013-06-25 Thread Jim Giner

On 6/25/2013 2:32 AM, OJFR wrote:

Yeah, Jim, please explain what u mean by "Per the manual, associative arrays
using string indices should always use ' ' around them.  They work (as
mentioned in the manual) but are wrong". As long as I remember  I could use
associative arrays in that way (ex. $_SESSION['Cust_Num']). There's another
way to do that using string indices? Why do you say it's wrong? It's
obsolete?

If YOU had taken the time to check the manual as I DID, you would not 
have blown your top at me.  When I said 'per the manual', I meant it. It 
was not something I made up to taunt Ethan with - it was from the place 
all of us here quote on a regular basis.


Apology accepted.

And if you were a regular participant in this helpful forum, you would 
know of my attitude when dealing with Mr. Rosenberg, PhD.


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



Re: [PHP-DB] Re: Problem with query

2013-06-25 Thread Jim Giner

On 6/25/2013 6:06 AM, Toby Hart Dyke wrote:


What Jim means is here in the manual:

http://www.php.net/manual/en/language.types.array.php#language.types.array.donts


In a nutshell:

Always use quotes around a string literal array index. For example,
/$foo['bar']/ is correct, while /$foo[bar]/ is not.

The reason is that without the quotes, you are generating an undefined
constant (bar) rather than using a string index ('bar'). It works, but
could have side effects in the future, so it's bad form to do it.

As for general politeness, you seem to be unaware of recent history in
this (an associated) groups. The OP has often committed the ultimate
sine. Not posting slightly wild code (we've all been/are there!) He
doesn't seem to listen or learn too well. Many posters (including Jim)
have offered a lot of of extremely good (and detailed) advice which
seems to be rarely taken...

   Toby


On 6/25/2013 7:32 AM, OJFR wrote:

Yeah, Jim, please explain what u mean by "Per the manual, associative
arrays
using string indices should always use ' ' around them.  They work (as
mentioned in the manual) but are wrong". As long as I remember  I
could use
associative arrays in that way (ex. $_SESSION['Cust_Num']). There's
another
way to do that using string indices? Why do you say it's wrong? It's
obsolete?

I would like to make a call to all the members of this mailing list:
knowledge is a wonderful gift so, why we don't share it politely and
efficiency. Jim, I will take you as an example. You start saying "
Against
my better judgement, here I go again".




My humble thanks for your timely support.  :)

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



[PHP-DB] Re: Problem with query

2013-06-23 Thread Jim Giner

On 6/23/2013 2:31 PM, Ethan Rosenberg, PhD wrote:

Dear List -

There is an error in my query, and I cannot find it.

This fails:

$_SESSION['Cust_Num'] = $_REQUEST['cnum'];
$_SESSION['CustNum'] = $_REQUEST['cnum'];

echo "session"; //this has the proper values
print_r($_SESSION);

$sql10 = "select Balance, Payments, Charges, Date from Charges where
Cust_Num = $_SESSION[Cust_Num] order by Date";
echo $sql10; //echos the correct query
$result10 = mysqli_query($cxn, $sql10);
var_dump($result1); // this returns NULL


Against my better judgement, here I go again.

Is this the "actual" code you executed, or is it once again a typeover?

Your 1st error is in these two lines:
> $result10 = mysqli_query($cxn, $sql10);
> var_dump($result1); // this returns NULL

Yes your dump returns null.  And always will.


Any further errors might be related to your non-standard syntax for the 
session variable.  Per the manual, associative arrays using string 
indices should always use ' ' around them.  They work (as mentioned in 
the manual) but are wrong.


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



Re: [PHP-DB] Sorting a PHP array

2013-05-16 Thread Jim Giner

On 5/15/2013 1:38 PM, Bastien wrote:



Bastien Koert

On 2013-05-15, at 12:32 PM, "Charlie Lewis"  wrote:


I have a bookseller database list read into a PHP array with dimensions
[row][field]. There are 32 fields in each record/row and up to 500 records.



What is the neatest way to sort the array by any of the fields, such as
author or title?



I know I should just search for a manual on this, but could anybody give me
a quick start?



Thanks,



Charlie



Mildly annoyed by your laziness so ima gonna point you to the manual

http://ca1.php.net/manual/en/function.array-multisort.php

Bastien




I learned something.  Never read up on this function.  Could be useful 
someday


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



[PHP-DB] Re: Sorting a PHP array

2013-05-15 Thread Jim Giner

On 5/15/2013 12:32 PM, Charlie Lewis wrote:

I have a bookseller database list read into a PHP array with dimensions
[row][field]. There are 32 fields in each record/row and up to 500 records.



What is the neatest way to sort the array by any of the fields, such as
author or title?



I know I should just search for a manual on this, but could anybody give me
a quick start?



Thanks,



Charlie




Sure you can sort this array, but you'd have to write your own I think. 
 Why not just order a query and use those results instead of an array?


A query should process pretty fast on almost any system.  Are you in 
need of such instantaneous response that you thought of going to an array?


You could have this query:

$q = "select author,title,year,media ... from books_table order by 
'$sortkey'"


where $sortkey can be a desired field name chosen by the user.  Could be 
a multi-fieldname sortkey as well.  Could be run as an ajax request if 
need be too.


So many better ways of doing this than an array IMHO.

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



Re: [PHP-DB] Placing a form on a page

2013-05-06 Thread Jim Giner
Centering a form is a simple process - as you stated about your first 
example form.  So - obviously the problem is in all that other crap you 
presented to us, expecting us to do your debugging.  I still don't know 
what you want to do - perhaps you could have given us a para on what it 
is wrong.  Are you trying to center multiple forms, or just align 
multiple forms in some fashion?


Once again - learn some new stuff and develop code that is easier to 
read and perhaps you'll find more of your own errors.  IE - read about 
"heredocs".  (That IS php!)


(You might also want to read about security and protecting yourself from 
malicious input values.)


Hope I didn't offend you again, but this post was just more of the same 
old "Ethan Phd" stuff.


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



Re: [PHP-DB] PDO Exceptions

2013-04-25 Thread Jim Giner

On 4/25/2013 6:49 AM, Niel Archer wrote:

Greetings,

I am new to this list. I have a question about which functions need to be 
included in a try block.

Of "new PDO", "prepare", "bindParam", "execute", "fetch", and "query", it seems 
that bindParam is the only one that throws an exception. So is this the only that needs to be put into a try block?

Thanks,

-KJW
Proverbs 3:5-6


Are you aware that there is a setting to control whether PDO objects throw
exceptions, warnings, or nothing? By default it does nothing except set
the error code and message.

See http://uk3.php.net/manual/en/pdo.error-handling.php

--
Niel Archer
niel.archer (at) blueyonder.co.uk


And I learn something new today too!

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



Re: [PHP-DB] Re: PDO Exceptions

2013-04-24 Thread Jim Giner

On 4/24/2013 10:04 AM, Lars Nielsen wrote:

On 4/24/2013 9:43 AM, Lars Nielsen wrote:

On 4/22/2013 11:55 AM, Onatawahtaw wrote:

Greetings,

I am new to this list. I have a question about which functions need to
be included in a try block.

Of "new PDO", "prepare", "bindParam", "execute", "fetch", and "query",
it seems that bindParam is the only one that throws an exception. So
is
this the only that needs to be put into a try block?

Thanks,

-KJW
Proverbs 3:5-6


Since nobody else has offered anything, I'll give you my impression of
how a try handles things.

If the statement(s) within the try block fail in any way (such as
simply
returning a 'false' value), the try block's catch will be executed.  So
while the items you specified do not "throw an exception", I believe
the
try will still handle a failure of those functions.

Of course, if I'm wrong, I'm positive we'll start seeing responses to
your question.  :)

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



Hi Jim,

I agree that failures would normally be catched as an exception. But how
do/can you determine if "false" is a failure?

/Lars


It's not a question of Me determining that.  If the original function
returned "false" then the try should catch it and in your 'catch' block
you can display a message and show the php error.  In the case where you
expect a 'false' return, then just reverse your try condition, and
display the appropriate message (without a php error messsage).  Or even
simpler, just use an If statement.

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



If the functions inside your try block doesnt throw anything, then your
code will not enter the catchblock. It does not depend on what your
function return, but what they throw.
/Lars


If that is true then  I learned something today.  :)

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



Re: [PHP-DB] Re: PDO Exceptions

2013-04-24 Thread Jim Giner

On 4/24/2013 9:43 AM, Lars Nielsen wrote:

On 4/22/2013 11:55 AM, Onatawahtaw wrote:

Greetings,

I am new to this list. I have a question about which functions need to
be included in a try block.

Of "new PDO", "prepare", "bindParam", "execute", "fetch", and "query",
it seems that bindParam is the only one that throws an exception. So is
this the only that needs to be put into a try block?

Thanks,

-KJW
Proverbs 3:5-6


Since nobody else has offered anything, I'll give you my impression of
how a try handles things.

If the statement(s) within the try block fail in any way (such as simply
returning a 'false' value), the try block's catch will be executed.  So
while the items you specified do not "throw an exception", I believe the
try will still handle a failure of those functions.

Of course, if I'm wrong, I'm positive we'll start seeing responses to
your question.  :)

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



Hi Jim,

I agree that failures would normally be catched as an exception. But how
do/can you determine if "false" is a failure?

/Lars

It's not a question of Me determining that.  If the original function 
returned "false" then the try should catch it and in your 'catch' block 
you can display a message and show the php error.  In the case where you 
expect a 'false' return, then just reverse your try condition, and 
display the appropriate message (without a php error messsage).  Or even 
simpler, just use an If statement.


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



[PHP-DB] Re: PDO Exceptions

2013-04-24 Thread Jim Giner

On 4/22/2013 11:55 AM, Onatawahtaw wrote:

Greetings,

I am new to this list. I have a question about which functions need to be 
included in a try block.

Of "new PDO", "prepare", "bindParam", "execute", "fetch", and "query", it seems 
that bindParam is the only one that throws an exception. So is this the only that needs to be put into a try block?

Thanks,

-KJW
Proverbs 3:5-6

Since nobody else has offered anything, I'll give you my impression of 
how a try handles things.


If the statement(s) within the try block fail in any way (such as simply 
returning a 'false' value), the try block's catch will be executed.  So 
while the items you specified do not "throw an exception", I believe the 
try will still handle a failure of those functions.


Of course, if I'm wrong, I'm positive we'll start seeing responses to 
your question.  :)


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



[PHP-DB] Re: Undefined variables in update query

2013-03-26 Thread Jim Giner

On 3/26/2013 11:19 AM, VanderHart, Robert wrote:

Hi,

I'm pretty new to PHP and to this discussion list.

I have a web form to update some fields in a data table.  I'm getting "undefined 
variable" notices in my error logs when I submit the form and the table row doesn't 
get updated.

Here's the code for the form page:

Editing Record  ";

for ($i=0; $i<$num; $i++) {
 $row = mysqli_fetch_assoc ($result);

 echo
"Last Name:
First Name:
Middle Name:
Suffix:
Email:
Institution:
Department:
Comments:
Send Email?$row[sent_email]
 ";

 }
echo " ";

?>

The data are inserted correctly into the form input fields, but when I click the "Update 
Author" button, an "undefined variable" notice gets logged for each of the variables 
and the table row doesn't get updated.  The only variable that seems to be OK is the authorid 
field; it outputs the correct ID from the var_dump() I have inserted.

Here's the code that processes the form:



Can anyone tell where I'm going wrong?  I thought it might be some obvious 
thing like the use of single quotes instead of double quotes in the update 
query, or vice-versa, but I've tried several different ways.  I've looked at 
numerous stackoverflow.com postings but nothing seems to remedy the issue I'm 
having.  I'm also wondering if the problem is related to my using echo() to 
output the form fields in the first template.

FWIW, here's the design of my table:

+-+--+--+-+-++
| Field   | Type   | Null  | Key | Default  | Extra 
 |
+-+--+--+-+-++
| email  | varchar(255)   | YES  | | NULL   |   
|
| institution | varchar(200)  | YES  | | NULL   |   
|
| lname| varchar(100)  | YES  | | NULL| 
  |
| fname   | varchar(80)| YES  | | NULL| 
   |
| mname   | varchar(20)  | YES  | | NULL   |
 |
| department  | varchar(200) | YES  | | NULL  | |
| comments| varchar(255) | YES  | | NULL   | |
| authorid| int(5) | NO   | PRI  | NULL| auto_increment 
|
| sent_email  | varchar(20)  | YES  |  | NULL|  
|
| suffix | varchar(50)| YES  || NULL |  
   |
+-+--+--+-+-++

Thanks for any help you can give me!

--
Robert J. Vander Hart
University of Massachusetts Medical School
508-856-3290 | robert.vanderh...@umassmed.edu



When referencing your query results (as in this line:

"Last Name:value=\"$row[lname]\">

>
)  you left out the quotes on the index  ($row['lname']).  That's at 
least some of your errors.  And - you might need to wrap those instances 
in {} too!



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



Re: [PHP-DB] Saving Image in mySQL

2013-03-20 Thread Jim Giner

On 3/20/2013 8:43 AM, Toby Hart Dyke wrote:


You're right - you're pulling $file out of thin air. Once uploaded, the
file is stored in $_FILES['file']['tmp_name'], and you need to manually
read the data into $file yourself. Something like:

   file_get_contents($_FILES['file']['tmp_name'])

   Toby


On 3/19/2013 8:15 PM, Ron Piggott wrote:

Hi All
I don’t understand how to save an image to a mySQL table based on the
following form. I am trying to do this using Prepared Statements.  All
the fields except the image file itself save in the database.  Right
now I have $file as the variable when binding the values.  What should
it be?  Ron



# bind variables

 $stmt->bindValue(':caption', 'Test Caption', PDO::PARAM_STR);
 $stmt->bindValue(':image_type', $_FILES["file"]["type"],
PDO::PARAM_STR);
 $stmt->bindValue(':image_size', $_FILES["file"]["size"],
PDO::PARAM_INT);
 $stmt->bindValue(':image_name', $_FILES["file"]["name"],
PDO::PARAM_STR);
 $stmt->bindValue(':image', $file, PDO::PARAM_STR);



And in doing this your destination would then be the final resting place 
for the image(s), with the pointer to each stored in your table  record 
for that image.  :)


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



Re: [PHP-DB] Saving Image in mySQL

2013-03-20 Thread Jim Giner
Absolutely - do not store any images in a db.  Makes no sense.  The data 
(the image) is static, basically safe from alteration or changing in any 
way, so what is the need?  Save the location/name of the image only and 
store all of them in one (or more) secured folders on the server.  No db 
overhead, no potential roadblocks as you grow your data tables and no 
excess time spent by the os storing and retrieving from the db.


Really - not a good idea.

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



Re: [PHP-DB] My Comments

2013-02-22 Thread Jim Giner

Ethan,

I've spent several hours - at least 7-8 - working with you on this 
latest project.  As you know it has morphed from one "problem" to 
another in the course of days.  Yes - miscommunication on your part 
which you took responsibility for.  That happens.  I even had a whole 
new pair of working scripts tested out and ready to send to you when you 
informed me of this snafu.  But - when you took the functional, working 
example scripts that I wrote and previously gave to you and turned them 
into something unrecognizable and non-functional I realized that I am 
helping the blind.  You don't know the least bit about html structure. 
You don't understand how to code in 3 different "languages" at the same 
time and make them readable, workable, and maintainable.   You also 
don't understand how to diagnose your problem and present it to this 
community in a way that's fathomable and understandable to someone who 
has no clue what your overall goal is.  Sure you may want to include the 
whole g..d... script at this point, but again, that's not what you want 
to do.  You need to debug, to isolate, and to work hard at getting to 
the root of your problem and then, and ONLY THEN, come to others with 
your request for help.  Present a clearly manageable and functioning 
piece of code that you feel is the problem area and ask for help on it.


It is also clear to me that you cannot see the forest for the trees when 
it comes to designing and developing your programming solutions.  After 
our miscommunication and the alteration of your solution from one 
involving an ajax call to obtain data "behind the scenes", two days 
later you post a request for help on exactly that thing.


Your latest plea for help was *impossible* to look at from the outside 
and help you with.  You had the same repeated statements in it.  You 
even had a loop executing twice in it - what's up with that?  You throw 
pieces of your coding attempts at us that clearly don't fit together and 
expect us to make something of it.


And lastly - you just don't get it.  You are dealing with a forum of 
people who have a better understanding of the things you are trying to 
grasp and yet you persevere in blaming us for not helping you.  This is 
not the first time you have complained about that.  And yet you haven't 
learned from it.


For the last time ( on my part at least), LOOKAT THE SCRIPTS I GAVE YOU. 
 STUDY THEM LIKE YOU WOULD A CHEMISTRY BOOK.  THIS IS THE WAY YOU 
SHOULD LEARN TO CODE.  From this point forward adopt *that* style of 
coding until you can morph it into your own style (which everyone has). 
 Only at that point will you be able to converse knowledgeably with the 
people here of whom you are asking for help.  Karl has clearly told you 
the same thing yet you took it with offense (as I'm sure you will this 
letter).  Think - there is a reason behind our harshness.  We could have 
just laughed ourselves silly and ignored your posts instead of putting 
time and effort into trying to interpret and help (when possible) and be 
faced time and again with the same clearly unmanageable contexts in your 
confusing posts.


You can choose to ignore this blatantly punishing post and call me 
whatever you wish.  I just could not ignore your silly rejoinder to the 
latest criticism of your attempt at coding.  I'm sure you regretted 
hitting Send almost immediately.


And one more thing - I realize that you are so very proud of that 'PhD' 
at the end of your name.  Well, I'm sure I can speak for many of us here 
- it means nothing.  Painfully obvious when you demonstrate such 
woefully poor computer skills that have not changed one bit in the 6-8 
months that I (and others) have been reading and responding to your 
posts.  Besides - it's a degree in Chemistry.  It's of no use here and I 
would think it's an embarassment to you by now that you continue to tout 
your academic prowess yet do not show the slightest bit of improvement 
as a student of PHP.


By the way - Fortran is nothing like the kind of involved technology 
that you are attempting to work with now.  Why do you keep pointing it 
out?  Many of us (older folks) here probably wrote Fortran at some point 
in our careers - do you think any of us remember the first thing about 
it?  Or use anything gleaned from it in today's world?


Sincerely, seriously, and known for holding no punches,
Jim Giner


ps - if you want my unsent, last attempts that I mentioned, drop me a 
line.  Or not.


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



Re: [PHP-DB] Ajax

2013-02-21 Thread Jim Giner

On 2/21/2013 2:34 AM, Karl DeSaulniers wrote:

Hi Ethan,
With all due respect, I really wish I could help, but your structure of
how your doing your
html and php and javascript mix doesn't make sense enough for me
to understand what it is your doing or how to help you. I copied and
pasted your original code
in my editor and it broke all over the place with the syntax
highlighting I have.
That is a big sign your code is not developed properly. Not even the
basic HTML.

I'd suggest getting yourself aquatinted with basic HTML structure first,
then continue with any front or back end languages like
learn how to get the value of fields vs. a TD and how to pass them to
functions.
How to echo php vars into javascript vars, etc.

Got to learn to crawl before you can walk as they say.

:)

GL,
Karl


ROFL


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



Re: [PHP-DB] Re: AJAX/Javascript??

2013-02-11 Thread Jim Giner

On 2/11/2013 10:08 AM, Michael Oki wrote:

Create a form and add a submit button that will run a php file.
The SQL query in the php file will have something like
"SELECT custName FROM table WHERE lname='$lname';
This will come after you have retrieved the data from a form like this
$lname = $_POST['lname'];




Michael,
The OP has the skills in hand to do what you proposed for him, as 
evidenced by his extensive posts on previous problems. From his subject 
line, I think he's more interested in an interactive ie, client-side, 
solution, but I could be totally off-base.  We'll just have to wait for 
Ethan's response to our posts.


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



[PHP-DB] Re: AJAX/Javascript??

2013-02-10 Thread Jim Giner

On 2/9/2013 10:51 PM, Ethan Rosenberg, PhD wrote:

I know that this might be an Ajax/Javascript question.  Hopefully you
can help.  I do not know of any other source for good info.

I would like to be able to click on one field in a table, and retrieve
the data in another field.  Here is the information:

The table is:

+--+--+--+-+-+---+
| Field| Type | Null | Key | Default | Extra |
+--+--+--+-+-+---+
| Cust_Num | smallint(5) unsigned | NO   | PRI | NULL|   |
| Fname| varchar(25)  | NO   | | NULL|   |
| Lname| varchar(25)  | NO   | | NULL|   |
| Street   | varchar(25)  | NO   | | NULL|   |
| City | varchar(25)  | NO   | | NULL|   |
| State| varchar(2)   | NO   | | NULL|   |
| Zip  | mediumint(9) | NO   | | NULL|   |
| Phone| int(10)  | NO   | | NULL|   |
| Date | date | NO   | | NULL|   |
| Notes| text | YES  | | NULL|   |
| P1   | int(3)   | YES  | | NULL|   |
| P2   | int(3)   | YES  | | NULL|   |
| P3   | int(4)   | YES  | | NULL|   |
+--+--+--+-+-+---+

Click on Lname and retrieve the Cust_Num.

Here is the sql query that will be used:

$sql12 = 'SELECT Cust_Num, Fname, Lname, Street, City, State, Zip,
Phone, Notes FROM Customers WHERE Cust_Num = $_POST['Cust_Num'];

[I'm actually doing this w/ prepared statements]

 $i = 0;
 do
 {
 {

 $vara2 = array(array($Cust_Num, $Fname,
$Lname, $Street, $City, $State, $Zip, $Phone, $Notes));
 $vara2[$i][0]= $Cust_Num;
 $vara2[$i][1]= $Fname;
 $vara2[$i][2]= $Lname;
 $vara2[$i][3]= $Street;
 $vara2[$i][4]= $City;
 $vara2[$i][5]= $State;
 $vara2[$i][6]= $Zip;
 $vara2[$i][7]= $Phone;
 $vara2[$i][8]= $Notes;

 $_SESSION['exe'] = 2;

?>

  
  
  
  
  
  
  
  

\n";
 $i = $i + 1;
 }
 } while (mysqli_stmt_fetch($stmt)); //end do-while
 $imax = $i;
 echo "";
 echo "";

 }//end count($errors_array)


Any ideas?

Eitan


I'm not sure what you are going to do with the customer number when you 
get it since you are outside of php but here's one way of getting it on 
the fly:


As you build your html table wtih php, assign an id to the name fields 
and the custno fields, such as 'id=name1' id='name2', etc. and 
'id=cust1', 'it=cust2' and so on.


On the name field also add an onclick=getCustNo($i) where $i has the 
value of the id value.  Then write a javascript function like:


function getCustNo(id)
{
var cno = "cust"+id;
var cname = "name"+id;
namefld = document.getElementById(cname).value;
custno = document.getElementById(cno).value;
alert("Customer "+namefld+ "has customer number "+custno);
return;
}

As I said - I don't know what you think you are going to do now but you 
got it.


PS - I might have used ".value" when it should be ".innerHTML" in the js 
code.  You'll have to experiment.


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



[PHP-DB] Re: Processing Account Login

2013-02-07 Thread Jim Giner

On 2/6/2013 8:01 PM, Ron Piggott wrote:

Hi Everyone

When I login to PayPal a total of 3 web pages are used:

1 – A screen for the user to type in their user name & password
2 – A screen saying “ Logging in “*
3 – My Welcome / Personalized Account Summary Screen

* During the 2nd web page my PHP script is going to be accessing the mySQL 
database to check the login credentials.


- I would like to know how this is done
- I would like to know how to re-direct the user to a “incorrect password” 
screen if this is the case
- I would like to know how to re-direct to a “security question” screen as a 
secondary step for those users who want this additional security (such as what 
I am offered through my online banking sign in process)

I don’t know what an effective search query is on Google.  I don’t mind (nor 
will I take offense) on being directed to a tutorial.  I want to ensure what I 
am putting into production is high quality and not hap hazard.

Thank you for any help you are able to provide me with.


Ron Piggott


www.TheVerseOfTheDay.info

There are so many MANY ways of accomplishing this, it's hard to begin. 
Since you seem to be unaware of this whole process, I imagine the 
simple, most-straight forward way would be the best.


YOu can do this with one script - if you are not wanting to be too fancy.

Upon first call - you display the login page and wait for a submit 
button to call your script again.


Upon the second call you gather the inputs and validate them, returning 
error messages if they are not present or not in the proper formats.  If 
inputs are acceptable, per se, then you perform your db check and 
respond accordingly (failure message or success message with a different 
target in your  tag). The output from this second call can be the 
same as the first call's if there's an error, or completely different if 
success was achieved - just change what html you send to the client.


If you want to prompt them for a security question before checking the 
database, that is just as easy.  In the "second call" you send back a 
different set of html prompting the user for the answer to the question 
that you display.  Then you do the above paragraph as the "third" call. 
 Of course you need to store the inputs received somewhere - probably 
not in hidden field, but rather session vars.  On the third call you 
collect the answer to the question, the session vars with the uid and 
pswd, and then do the db check.


As I said - you can do this with one script.  You simply have different 
chunks of html that your script outputs, depending upon the step you are 
in.  That 'step' is some indicator of your making that you hide in the 
html so that your script knows where it is in the conversation with the 
user.  You also have different chunks of php code to handle the 
different steps.


Piece of cake!

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



Re: [PHP-DB] pdo ?

2013-01-25 Thread Jim Giner

On 1/25/2013 10:56 AM, Jim Giner wrote:

On 1/24/2013 7:07 PM, Matt Pelmear wrote:

On 01/24/2013 04:02 PM, Jim Giner wrote:


I took my 6 line override php.ini file and replicated (with a script)
into all of my possible folders under my web root.  NOt exactly an
elegant solution, but with the script, easy to maintain.



Honestly, you would be better off just putting those 6 overrides into
your common include file.
I'm curious why would you do that as opposed to just putting it in the
webroot with a single .htaccess file (or changing the global php.ini)?

I don't have access to the global ini file.  As for .htaccess - I
thought your previous (?) said I would need to have multiple of them also.
Upon further research - I find that my domain has .htaccess files 
throughout the entire directory structure - not by my doing.  So I'm 
guessing that would mean having my individual php settings applied to each?


I think that I'll stay with a php.ini override file in each of my 
executable folders - now that I have the script necessary to easily 
apply new versions from my master one when needed.


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



Re: [PHP-DB] pdo ?

2013-01-25 Thread Jim Giner

On 1/24/2013 7:07 PM, Matt Pelmear wrote:

On 01/24/2013 04:02 PM, Jim Giner wrote:


I took my 6 line override php.ini file and replicated (with a script)
into all of my possible folders under my web root.  NOt exactly an
elegant solution, but with the script, easy to maintain.



Honestly, you would be better off just putting those 6 overrides into
your common include file.
I'm curious why would you do that as opposed to just putting it in the
webroot with a single .htaccess file (or changing the global php.ini)?
I don't have access to the global ini file.  As for .htaccess - I 
thought your previous (?) said I would need to have multiple of them also.


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



Re: [PHP-DB] pdo ?

2013-01-24 Thread Jim Giner

On 1/24/2013 6:09 PM, Matt Pelmear wrote:

On 01/24/2013 01:34 PM, Jim Giner wrote:


If you are using another web server or running PHP as FastCGI you may
need to consider other options (changing the setting globally or doing a
require_once() of your config changes?, or see the FastCGI example here:
http://www.askapache.com/php/php-htaccess-tips-tricks.html)

-Matt

It sounds like I'll have to modify multiple htaccess files - which is
about the same as this php.ini problem - having multiples perhaps.

I've been working fine with a php.ini that merges onto the "full" ini
file.  Suddenly this new appl is not seeing the overrides.

Any info you can point me to about how php.ini files work?  The manual
doesn't get very specific about it.



You would only have to modify multiple .htaccess files if you have
multiple document roots that need this change applied to them.
Otherwise just create/edit the .htaccess file in the document root for
the site you want the change applied to.
.htacess isn't always read by Apache. Some configurations tell it to
read or not read that file, so you may need to check that as well.

phpinfo() will tell you which php.ini file is being used-- if you edit
the one it says is being used you should see a change unless something
else is overriding the setting (like an .htaccess file or your code).

-Matt

I took my 6 line override php.ini file and replicated (with a script) 
into all of my possible folders under my web root.  NOt exactly an 
elegant solution, but with the script, easy to maintain.


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



Re: [PHP-DB] pdo ?

2013-01-24 Thread Jim Giner

On 1/24/2013 6:03 PM, Matt Pelmear wrote:

On 01/24/2013 01:37 PM, Karl DeSaulniers wrote:


On Jan 24, 2013, at 2:15 PM, Matt Pelmear wrote:


On 01/24/2013 12:00 PM, Jim Giner wrote:

On 1/24/2013 1:41 PM, Richard Quadling wrote:

On 24 January 2013 17:48, Matt Pelmear  wrote:

On 01/24/2013 09:23 AM, Jim Giner wrote:


On 1/24/2013 12:05 PM, Matt Pelmear wrote:



http://stackoverflow.com/questions/5801951/does-php-auto-escapes-quotes-in-string-which-is-passed-by-get-or-post



Every pro has this feature (magic_quotes_gpc) turned off. If you
understand SQL Injection vulnerabilities, and properly bind
things into
your queries, I would recommend disabling it.

-Matt

On 01/24/2013 08:55 AM, Jim Giner wrote:


ok - new to using pdo functions, but I thought I had a handle
on it.

I'm writing out to my page an input tag with the following
value in it:

49'ers

I can confirm it by using my browser's "view source" to see
that is
exactly how it exists in the page.

When I hit a submit button and my script retrieves the 'post'
vars my
debugging steps are showing that the var $_POST['team']
contains the
above value with a backslash (\) already inserted. This is
causing me
a problem when I then try to use pdo->quote to safely encode it
for
updating my sql database.

My question is - why does the POST var show the \ char before I
execute the 'quote' function?




You're right!  But I must not understand something.

My root folder has a php.ini file with the magic quotes set off.
Doesn't
that carry on down to folders beneath it?



I would check phpinfo() to see if it is being overridden.

-Matt


Create an info.php file containing ...


Matt & Rich,

I have a small php.ini in my domain's  'php' folder as well as in my
webroot folder. I was under the impression that the overrides would
be applied to all folders below my webroot, but apparently it is not
happening.

How do 'pros' replicate their .ini settings thru all of the
application folder?  Not thru settings within the scripts I hope - I
thought I read that the was not a very efficient way to do it and
that a php.ini file was the best since it would be merged with the
master one installed by my hoster.



Jim,

Personally I rarely have the need to override the php.ini settings
for a particular host on a server. (Granted I never work in shared
servers)
Assuming you are using Apache and the standard module configuration,
you can use .htaccess files to override many settings from php.ini

Official reference pages:
http://php.net/manual/en/configuration.changes.php  (you might want
to read through the comments here, too)
http://httpd.apache.org/docs/current/howto/htaccess.html

Example and some discussion here as well:
http://davidwalsh.name/php-values-htaccess

If you are using another web server or running PHP as FastCGI you may
need to consider other options (changing the setting globally or
doing a require_once() of your config changes?, or see the FastCGI
example here:
http://www.askapache.com/php/php-htaccess-tips-tricks.html)

-Matt

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




You could just check for it with php and add or strip accordingly.

adding slashes if magic_quotes is disabled:

if (!get_magic_quotes_gpc()) {
$var = addslashes($var);
}

stripping slashes if magic_quotes is enabled and your planning on
sanitizing yourself.

if (get_magic_quotes_gpc()) {
$var = stripslashes($var);
//do your own sanitizing
}

I wouldn't suggest the last one if your not going to sanitize yourself
as it will make you vulnerable.
But all-in-all very simple to implement.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com




You shouldn't be sanitizing using addslashes() regardless, or using
magic_quotes_gpc at all really, if you can help it.
See: http://php.net/manual/en/security.magicquotes.whynot.php
(magic_quotes was deprecated because it is bad.)

-Matt


And I'm not.

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



Re: [PHP-DB] pdo ?

2013-01-24 Thread Jim Giner

On 1/24/2013 4:37 PM, Karl DeSaulniers wrote:


On Jan 24, 2013, at 2:15 PM, Matt Pelmear wrote:


On 01/24/2013 12:00 PM, Jim Giner wrote:

On 1/24/2013 1:41 PM, Richard Quadling wrote:

On 24 January 2013 17:48, Matt Pelmear  wrote:

On 01/24/2013 09:23 AM, Jim Giner wrote:


On 1/24/2013 12:05 PM, Matt Pelmear wrote:



http://stackoverflow.com/questions/5801951/does-php-auto-escapes-quotes-in-string-which-is-passed-by-get-or-post



Every pro has this feature (magic_quotes_gpc) turned off. If you
understand SQL Injection vulnerabilities, and properly bind
things into
your queries, I would recommend disabling it.

-Matt

On 01/24/2013 08:55 AM, Jim Giner wrote:


ok - new to using pdo functions, but I thought I had a handle on
it.

I'm writing out to my page an input tag with the following value
in it:

49'ers

I can confirm it by using my browser's "view source" to see that is
exactly how it exists in the page.

When I hit a submit button and my script retrieves the 'post'
vars my
debugging steps are showing that the var $_POST['team'] contains
the
above value with a backslash (\) already inserted. This is
causing me
a problem when I then try to use pdo->quote to safely encode it for
updating my sql database.

My question is - why does the POST var show the \ char before I
execute the 'quote' function?




You're right!  But I must not understand something.

My root folder has a php.ini file with the magic quotes set off.
Doesn't
that carry on down to folders beneath it?



I would check phpinfo() to see if it is being overridden.

-Matt


Create an info.php file containing ...


Matt & Rich,

I have a small php.ini in my domain's  'php' folder as well as in my
webroot folder. I was under the impression that the overrides would
be applied to all folders below my webroot, but apparently it is not
happening.

How do 'pros' replicate their .ini settings thru all of the
application folder?  Not thru settings within the scripts I hope - I
thought I read that the was not a very efficient way to do it and
that a php.ini file was the best since it would be merged with the
master one installed by my hoster.



Jim,

Personally I rarely have the need to override the php.ini settings for
a particular host on a server. (Granted I never work in shared servers)
Assuming you are using Apache and the standard module configuration,
you can use .htaccess files to override many settings from php.ini

Official reference pages:
http://php.net/manual/en/configuration.changes.php  (you might want to
read through the comments here, too)
http://httpd.apache.org/docs/current/howto/htaccess.html

Example and some discussion here as well:
http://davidwalsh.name/php-values-htaccess

If you are using another web server or running PHP as FastCGI you may
need to consider other options (changing the setting globally or doing
a require_once() of your config changes?, or see the FastCGI example
here: http://www.askapache.com/php/php-htaccess-tips-tricks.html)

-Matt

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




You could just check for it with php and add or strip accordingly.

adding slashes if magic_quotes is disabled:

if (!get_magic_quotes_gpc()) {
 $var = addslashes($var);
}

stripping slashes if magic_quotes is enabled and your planning on
sanitizing yourself.

if (get_magic_quotes_gpc()) {
 $var = stripslashes($var);
 //do your own sanitizing
}

I wouldn't suggest the last one if your not going to sanitize yourself
as it will make you vulnerable.
But all-in-all very simple to implement.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


Not the problem.  I have other overrides that I need to include somehow.

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



Re: [PHP-DB] pdo ?

2013-01-24 Thread Jim Giner


If you are using another web server or running PHP as FastCGI you may
need to consider other options (changing the setting globally or doing a
require_once() of your config changes?, or see the FastCGI example here:
http://www.askapache.com/php/php-htaccess-tips-tricks.html)

-Matt
It sounds like I'll have to modify multiple htaccess files - which is 
about the same as this php.ini problem - having multiples perhaps.


I've been working fine with a php.ini that merges onto the "full" ini 
file.  Suddenly this new appl is not seeing the overrides.


Any info you can point me to about how php.ini files work?  The manual 
doesn't get very specific about it.


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



Re: [PHP-DB] pdo ?

2013-01-24 Thread Jim Giner

On 1/24/2013 1:41 PM, Richard Quadling wrote:

On 24 January 2013 17:48, Matt Pelmear  wrote:

On 01/24/2013 09:23 AM, Jim Giner wrote:


On 1/24/2013 12:05 PM, Matt Pelmear wrote:



http://stackoverflow.com/questions/5801951/does-php-auto-escapes-quotes-in-string-which-is-passed-by-get-or-post


Every pro has this feature (magic_quotes_gpc) turned off. If you
understand SQL Injection vulnerabilities, and properly bind things into
your queries, I would recommend disabling it.

-Matt

On 01/24/2013 08:55 AM, Jim Giner wrote:


ok - new to using pdo functions, but I thought I had a handle on it.

I'm writing out to my page an input tag with the following value in it:

49'ers

I can confirm it by using my browser's "view source" to see that is
exactly how it exists in the page.

When I hit a submit button and my script retrieves the 'post' vars my
debugging steps are showing that the var $_POST['team'] contains the
above value with a backslash (\) already inserted. This is causing me
a problem when I then try to use pdo->quote to safely encode it for
updating my sql database.

My question is - why does the POST var show the \ char before I
execute the 'quote' function?




You're right!  But I must not understand something.

My root folder has a php.ini file with the magic quotes set off. Doesn't
that carry on down to folders beneath it?



I would check phpinfo() to see if it is being overridden.

-Matt


Create an info.php file containing ...


Matt & Rich,

I have a small php.ini in my domain's  'php' folder as well as in my 
webroot folder. I was under the impression that the overrides would be 
applied to all folders below my webroot, but apparently it is not happening.


How do 'pros' replicate their .ini settings thru all of the application 
folder?  Not thru settings within the scripts I hope - I thought I read 
that the was not a very efficient way to do it and that a php.ini file 
was the best since it would be merged with the master one installed by 
my hoster.


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



Re: [PHP-DB] pdo ?

2013-01-24 Thread Jim Giner

On 1/24/2013 12:05 PM, Matt Pelmear wrote:

http://stackoverflow.com/questions/5801951/does-php-auto-escapes-quotes-in-string-which-is-passed-by-get-or-post


Every pro has this feature (magic_quotes_gpc) turned off. If you
understand SQL Injection vulnerabilities, and properly bind things into
your queries, I would recommend disabling it.

-Matt

On 01/24/2013 08:55 AM, Jim Giner wrote:

ok - new to using pdo functions, but I thought I had a handle on it.

I'm writing out to my page an input tag with the following value in it:

49'ers

I can confirm it by using my browser's "view source" to see that is
exactly how it exists in the page.

When I hit a submit button and my script retrieves the 'post' vars my
debugging steps are showing that the var $_POST['team'] contains the
above value with a backslash (\) already inserted. This is causing me
a problem when I then try to use pdo->quote to safely encode it for
updating my sql database.

My question is - why does the POST var show the \ char before I
execute the 'quote' function?




You're right!  But I must not understand something.

My root folder has a php.ini file with the magic quotes set off. 
Doesn't that carry on down to folders beneath it?


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



[PHP-DB] pdo ?

2013-01-24 Thread Jim Giner

ok - new to using pdo functions, but I thought I had a handle on it.

I'm writing out to my page an input tag with the following value in it:

49'ers

I can confirm it by using my browser's "view source" to see that is 
exactly how it exists in the page.


When I hit a submit button and my script retrieves the 'post' vars my 
debugging steps are showing that the var $_POST['team'] contains the 
above value with a backslash (\) already inserted.  This is causing me a 
problem when I then try to use pdo->quote to safely encode it for 
updating my sql database.


My question is - why does the POST var show the \ char before I execute 
the 'quote' function?


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



[PHP-DB] Re: PDO ?

2013-01-15 Thread Jim Giner
Never Mind  A little careful re-reading of the docs told me what I 
was doing wrong.


I always use PDO::FETCH_ASSOC in my fetch statements.  Discovered that I 
have to have numerical array results in order to utilize the List command.


Voila!

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



[PHP-DB] PDO ?

2013-01-15 Thread Jim Giner

Doing some conversion - looking for a solution.

Currently I do something like this:

while (list($var1,$var2) = mysql_fetch_array($qrslts))
{
handle the vars
}

Is there something in the PDO functions that emulates this same ability? 
 Some of my uses of the sql syntax have many more vars and I'm
trying to avoid having to move the fetch-ed fields one at a time to vars 
that I wish to use.

I already tried:

list($var1,$var2) = $qrslts->fetch(PDO::FETCH_ASSOC);

this does not populate the vars.

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



[PHP-DB] Re: Preventing repetition of a Form

2013-01-07 Thread Jim Giner

On 1/7/2013 7:00 PM, Ethan Rosenberg, PhD wrote:

Dear list -

I have a program [*pseudo code*]:

if(!isset($_REQUEST["welcome_already_seen"]))
{
 initialize variables
}

   $errors_array = array();
 if($_REQUEST["welcome_already_seen"]== "already_seen")
 {
 check_data();
if(count($errors_array) != 0)
{
 show_errors();
 show_welcome();
 }
 else
 {
 show_welcome();
 }
 }
 if(!isset($_REQUEST["welcome_already_seen"]))
   show_welcome();

 switch ( $_POST['next_step'] )
 {

 case "step5":
 {
 do something
 form
 next_step = step8;
/form
 }

 case "step10":
 {
 do something
 form
 next_step = step5;
  /form
}

 etc...etc
 } //end switch

 function show_welcome()
 {
do something
 form
 next_step = step10;
 /form
   }

The  show_welcome() persists in each step.

How do I make it go away after step10?

Thanks.

Ethan

I don't know why you expect anyone to tell you how to debug "pseudo 
code".  Good luck with that.



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



[PHP-DB] Re: Programs not Running - SOLVED

2013-01-06 Thread Jim Giner

On 1/6/2013 7:17 PM, Ethan Rosenberg, PhD wrote:

Dear List -

Thanks to all for your help.

The problem was in this piece of code:

 require '/var/www/pass.inc';
 $db = "Store";
 $cxn = mysqli_connect($host,$user,$password,$db);
 if ( !$cxn ) {
   die( 'connect error: '.mysqli_connect_error() );
 }

I had moved the password file [/var/www/pass.inc] out of root, but
forgot to change the code!

This still leaves a question:

 if ( !$cxn ) {
   die( 'connect error: '.mysqli_connect_error() );
 }

Why did the above code catch the error??

Ethan


You're asking why the die was reached rather than having a fatal error 
occur because the require couldn't be performed?  Perhaps because there 
exists another "pass.inc" file somewhere in PHP's default search folders 
for the require, but it contained the wrong password?


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



Re: [PHP-DB] Programs not running

2013-01-04 Thread Jim Giner
Is the failing one a .php file?

jg


On Jan 3, 2013, at 11:54 PM, "Ethan Rosenberg, PhD" 
 wrote:

> 
> On 01/03/2013 10:14 PM, Matt Pelmear wrote:
>> 
>> In addition to Jim's comments, 
>> 
>> Have you checked to see whether the permissions on all files are appropriate 
>> on the environment where this doesn't work? 
>> Are you running this in a web environment or CLI? If web, are you 100% sure 
>> the web server configuration is correct? 
>> 
>> -Matt 
>> 
>> On 01/03/2013 04:35 PM, Ethan Rosenberg, PhD wrote: 
>>> Dear List - 
>>> 
>>> I am running sid on my Lenovo desktop and squeeze on my Dell laptop.  The 
>>> php.ini files are the same.  The programs are the same except foro the 
>>> locatioln of the password file and of a file to be read for parameters. The 
>>> programs run beautifully on the desktop, but refuse to run on the laptop.  
>>> Error_reporting is set to -1. I receive no errors. 
>>> 
>>> Advice and help, please. 
>>> 
>>> Ethan 
> =
> Jim and Matt -
> 
> Did all the suggested debugging prior to sending the eml.  Note - 
> error_reporting(-1).  I hope that should catch anything.  If it helps, the 
> programs with just HTML code run OK.  the ones with  HTML/PHP do not.  In 
> fact, one of the HTML/PHP programs does not give any output at all, even w/ a 
> character string; eg, dtgfsvc, at the beginning f the code.
> 
> Are you running this in a web environment or CLI? If web, are you 100% sure 
> the web server configuration is correct? 
> 
> I can't answer because I do not understand.  gives the 
> correct output.
> 
> Hopefully, all the above should give us some hints at how to proceed.
> 
> Ethan
> 

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



Re: [PHP-DB] Programs not running

2013-01-04 Thread Jim Giner


On 01/03/2013 08:54 PM, Ethan Rosenberg, PhD wrote:

=

I can't answer because I do not understand.  gives
the correct output.



Ethan - whatever do you mean the phpinfo gives the correct output?  Do 
you mean that you compared every line and found them to match EXCEPT 
where you made deliberate changes?  Personally, I have very little idea 
about what is correct when I look at a phpinfo dump.  I just look to see 
what I expect to be set (by me) and let the rest go.  So much of it is 
meaningless to me - I let my host admins worry about the rest.



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



[PHP-DB] Re: Programs not running

2013-01-03 Thread Jim Giner

On 1/3/2013 7:35 PM, Ethan Rosenberg, PhD wrote:

Dear List -

I am running sid on my Lenovo desktop and squeeze on my Dell laptop. The
php.ini files are the same.  The programs are the same except foro the
locatioln of the password file and of a file to be read for parameters.
The programs run beautifully on the desktop, but refuse to run on the
laptop.  Error_reporting is set to -1. I receive no errors.

Advice and help, please.

Ethan
? #1 - are you sure that the two things you admit changing are actually 
working correctly?
Basic debugging here.  Verify the access of the password file with an 
echo/exit().  Then do the same for the parameter file read.  Then start 
moving that echo/exit() to somewhere later and later.


BTW - Can we lose the "a and c, p" comment?  I find it offputting.

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



[PHP-DB] Re: Prepared Statements - Search

2012-12-03 Thread Jim Giner

On 12/3/2012 2:30 PM, Ethan Rosenberg, PhD wrote:

Dear List -

I am trying to use prepared statements with the following code:

 $allowed_fields = array
 ('Cust_Num' => 'i',  'Fname' => 's', 'Lname' =>
's', 'Street' => 's','City'=> 's',   'State' => 's',   'Zip' => 'i',
 'Phone' => 'i', 'Notes' => 's'
 );

 if(empty($allowed_fields))
 {
  echo "ouch";
 }

 // Configure the query and the acceptable params to put
into the WHERE clause
 $sql12 = 'SELECT * FROM Customers WHERE 1';

// Magically put everything together
 $types = '';
 $args = array();
 foreach( $allowed_fields as $k => $type )
 {
  if( !array_key_exists( $k, $allowed_fields ) )
 continue;
 else
 {
 if( ($_POST[$k]) != '')
 {
 $args[] = &$_POST[$k]; // Note the addition
of the ampersand here
 $types .= $type;
 $sql12 .= " AND ($k = ?)";
 }
 }
 }

 $stmt = mysqli_stmt_init($cxn);
 mysqli_stmt_prepare( $stmt, $sql12 );

The search fails.

This debug code:

 echo "For debugging and demonstration #1";
 echo 'Query: ' . $sql12 . PHP_EOL;
 echo 'Bind types: ' . $types . PHP_EOL;
 echo "arguments";
 print_r($args);

gives the following results:


For debugging and demonstration #1
Query: SELECT * FROM Customers WHERE 1 AND (Fname = ?) AND (Lname = ?)
AND (Street = ?) AND (City = ?) AND (State = ?) AND (Zip = ?) AND (Phone
= ?)
Bind types: sii
arguments
Array
(
 [0] =>
 [1] =>
 [2] =>
 [3] =>
 [4] =>
 [5] =>
 [6] =>  845745745
)

If I search the database from the command line, these are the results -


mysql>  select * from Customers where Phone=845745745;
+--+-+--+++---+---+---++-+--+--+--+

| Cust_Num | Fname   | Lname| Street | City   | State | Zip   |
Phone | Date   | Notes   | P1   | P2   | P3   |
+--+-+--+++---+---+---++-+--+--+--+

|10016 | okuibtg | uymkibtvgfrc | p7tvgf | Monsey | NY|   127 |
845745745 | 2012-12-01 |   tvgfuyholkijuhy   | NULL | NULL | NULL |
|10017 | okuibtg | uymkibtvgfrc | p7tvgf | Monsey | NY| 10952 |
845745745 | 2012-12-01 |   tvgfuyholkijuhy   | NULL | NULL | NULL |
|10018 | okuibtg | uymkibtvgfrc | p7tvgf | Monsey | NY| 32767 |
845745745 | 2012-12-02 |   tvgfuyholkijuhy   | NULL | NULL | NULL |
+--+-+--+++---+---+---++-+--+--+--+

3 rows in set (0.00 sec)

This is the output routine:

 if(count($errors_array) == 0)
 {
 ?>

 Search Results
 
 
 
 Cust_Num
 First Name
 Last Name
 Street
 City
 State
 Zip
 Phone
 Notes




 


 
 
 
 
 
 
 
 
  
 
 \n";
 $i = $i + 1;
 }
 } while (mysqli_stmt_fetch($stmt)); //end do-while
 $imax = $i;
 echo "";
 echo "";
 echo "";


Help and advice, please.

Ethan





Yu say the statement fails.  Did you trap the execution of it and do you 
have an error message to show us?


My only other comment is (not having utilized perp-stmts very much at 
all yet) - what happens when your args are all ?'s?  I mean - if you say 
"where First=? and Phone=?" what happens when you don't supply all the ? 
with values?  My interpretation of the query would be that it ends up 
looking like this:  "Where First='' and Phone=845745745", which is 
probably not the query you want to be running.


BTW - a phone number is not really e

[PHP-DB] Re: Prepared Statements - Search

2012-12-03 Thread Jim Giner

On 12/3/2012 2:30 PM, Ethan Rosenberg, PhD wrote:

Dear List -

I am trying to use prepared statements with the following code:

 $allowed_fields = array
 ('Cust_Num' => 'i',  'Fname' => 's', 'Lname' =>
's', 'Street' => 's','City'=> 's',   'State' => 's',   'Zip' => 'i',
 'Phone' => 'i', 'Notes' => 's'
 );

 if(empty($allowed_fields))
 {
  echo "ouch";
 }

 // Configure the query and the acceptable params to put
into the WHERE clause
 $sql12 = 'SELECT * FROM Customers WHERE 1';

// Magically put everything together
 $types = '';
 $args = array();
 foreach( $allowed_fields as $k => $type )
 {
  if( !array_key_exists( $k, $allowed_fields ) )
 continue;
 else
 {
 if( ($_POST[$k]) != '')
 {
 $args[] = &$_POST[$k]; // Note the addition
of the ampersand here
 $types .= $type;
 $sql12 .= " AND ($k = ?)";
 }
 }
 }

 $stmt = mysqli_stmt_init($cxn);
 mysqli_stmt_prepare( $stmt, $sql12 );

The search fails.

This debug code:

 echo "For debugging and demonstration #1";
 echo 'Query: ' . $sql12 . PHP_EOL;
 echo 'Bind types: ' . $types . PHP_EOL;
 echo "arguments";
 print_r($args);

gives the following results:


For debugging and demonstration #1
Query: SELECT * FROM Customers WHERE 1 AND (Fname = ?) AND (Lname = ?)
AND (Street = ?) AND (City = ?) AND (State = ?) AND (Zip = ?) AND (Phone
= ?)
Bind types: sii
arguments
Array
(
 [0] =>
 [1] =>
 [2] =>
 [3] =>
 [4] =>
 [5] =>
 [6] =>  845745745
)

If I search the database from the command line, these are the results -


mysql>  select * from Customers where Phone=845745745;
+--+-+--+++---+---+---++-+--+--+--+

| Cust_Num | Fname   | Lname| Street | City   | State | Zip   |
Phone | Date   | Notes   | P1   | P2   | P3   |
+--+-+--+++---+---+---++-+--+--+--+

|10016 | okuibtg | uymkibtvgfrc | p7tvgf | Monsey | NY|   127 |
845745745 | 2012-12-01 |   tvgfuyholkijuhy   | NULL | NULL | NULL |
|10017 | okuibtg | uymkibtvgfrc | p7tvgf | Monsey | NY| 10952 |
845745745 | 2012-12-01 |   tvgfuyholkijuhy   | NULL | NULL | NULL |
|10018 | okuibtg | uymkibtvgfrc | p7tvgf | Monsey | NY| 32767 |
845745745 | 2012-12-02 |   tvgfuyholkijuhy   | NULL | NULL | NULL |
+--+-+--+++---+---+---++-+--+--+--+

3 rows in set (0.00 sec)

This is the output routine:

 if(count($errors_array) == 0)
 {
 ?>

 Search Results
 
 
 
 Cust_Num
 First Name
 Last Name
 Street
 City
 State
 Zip
 Phone
 Notes




 


 
 
 
 
 
 
 
 
  
 
 \n";
 $i = $i + 1;
 }
 } while (mysqli_stmt_fetch($stmt)); //end do-while
 $imax = $i;
 echo "";
 echo "";
 echo "";


Help and advice, please.

Ethan






What is your question?

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



[PHP-DB] Re: Formatting - Solved

2012-11-26 Thread Jim Giner

On 11/26/2012 1:04 PM, Ethan Rosenberg, PhD wrote:

Dear list

Here is the answer

 ORIGINAL

Search Results





Site
Medical Record
First Name
Last Name
Phone
Height
Sex
History
Birthday
Age



\n";
 $_SESSION['exe'] = 2;
?>
  
  
  
  
  
  
  

  
  
\n";
 $i = $i +1;

 }
 } while (mysqli_stmt_fetch($stmt)); //end do-while
 $imax = $i;
 echo "";
 echo "";
 echo "";

 }//end count($errors_array)


THIS IS THE CORRECTED VERSION:

 if(count($errors_array) == 0)
 {
?>

Search Results



Site
Medical Record
First Name
Last Name
Phone
Height
Sex
History
Birthday
Age



\n";
 $_SESSION['exe'] = 2;
?>



  
  
  
  
  
  
  

  
  
\n";
 $i = $i +1;
 }
 } while (mysqli_stmt_fetch($stmt)); //end do-while
 $imax = $i;
 echo "";
 echo "";
 echo "";
?>

 AFTER EACH  LINE

That was the problem!!!

Ethan

Did not notice; was not looking for them.  Of course if you knew about 
html tables you would know not to put them in there.  A little knowledge 
seems to be the root of all your bugs once again.


You really should read up on HEREDOCS in the php manual.  It will save 
you mucho amounts of typing and confusion when mixing php and html code.


Ex.

$code =<<
$vara2[$i][0]
$vara2[$i][1]
$vara2[$i][2]
$vara2[$i][3]
$vara2[$i][4]
$vara2[$i][5]
$vara2[$i][6]
$vara2[$i][7]
$vara2[$i][8]
$vara2[$i][9]

heredocs;
echo $code;

This does all that you code does with much less chafe in the code.


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



Re: [PHP-DB] Re: Formatting

2012-11-25 Thread Jim Giner

On 11/25/2012 5:39 PM, Ethan Rosenberg, PhD wrote:

List -

Any more ideas.
=
Keep on debugging

jg

Jim -

I've been at this for a few weeks, and am stuck.
Thanks for all your help.

Ethan

+

On Nov 25, 2012, at 1:59 PM, "Ethan Rosenberg, PhD"
 wrote:


On 11/25/2012 12:56 PM, Jim Giner wrote:


On 11/25/2012 12:46 PM, Ethan Rosenberg, PhD wrote:

Dear list -

When I run the following code, the results are preceded by at least one
screen full of blank lines. I am showing you a large code block since I
do not know where the error is:

 if(isset($_REQUEST['Sex'])&& trim($_POST['Sex']) != '' )
 {
 if ($_REQUEST['Sex'] === "0")
 {
 $sex = 'Male';
 }

 else
 {
 $sex = 'Female';
 }

  }
 $allowed_fields = array
 ('Site' => 's',  'MedRec' => 'i', 'Fname' => 's',
'Lname' => 's','Phone'=> 's',   'Height' => 'i',   'Sex' => 's',
 'Hx' => 's','Bday' => 's',  'Age' => 'i'
 );

 if(empty($allowed_fields))
 {
  echo "ouch";
 }

 // Configure the query and the acceptable params to put
into the WHERE clause
 $sql12 = 'SELECT * FROM Intake3 WHERE 1';

// Magically put everything together
 $types = '';
 $args = array();
 foreach( $allowed_fields as $k => $type )
 {
  if( !array_key_exists( $k, $allowed_fields ) )
 continue;
 else
 {
 if( ($_POST[$k]) != '')
 {
 $args[] = &$_POST[$k]; // Note the addition of
the ampersand here
 $types .= $type;
 $sql12 .= " AND ($k = ?)";
 }
 }
 }
 $stmt = mysqli_stmt_init($cxn);
 mysqli_stmt_prepare( $stmt, $sql12 );

 if( !$stmt )
 throw new Exception( 'Error preparing statement' );

 // Put the statement and types variables at the front of
the params to pass to mysqli_stmt_bind_param()
 array_unshift( $args, $stmt, $types ); // Note that I've
moved this call. Apparently it doesn't pass back the result. I guess
sometimes I just forget these things.

 // mysqli_stmt_bind_param()
 if( !call_user_func_array( 'mysqli_stmt_bind_param',
$args ) )
 throw new Exception( 'Failed calling
mysqli_stmt_bind_param' );

 if( !mysqli_stmt_execute( $stmt ) )
 throw new Exception( 'Error while executing
statement' );

 mysqli_stmt_bind_result( $stmt,  $Site, $MedRec, $Fname,
$Lname, $Phone, $Height, $Sex, $Hx, $Bday, $Age);




 if(count($errors_array) == 0)
 {


?>
Search Results





Site
Medical Record
First Name
Last Name
Phone
Height
Sex
History
Birthday
Age



\n";
 $_SESSION['exe'] = 2;
?>
  
  
  
  
  
  
  

  
  
\n";
 $i = $i +1;

 }
 } while (mysqli_stmt_fetch($stmt)); //end do-while
 $imax = $i;
 echo "";
 echo "";
 echo "";

 }//end count($errors_array)

Help and advice, please

Ethan


If this is the ACTUAL code you are executing you need to remember to
NOT include any blank lines.  Each and every one gets echoed to the
client and with all the blank lines I see above, that could very well
be a full but empty page.


+
Jim -

Thank you.

I removed all the blank lines, and get the same behavior.

Ethan

Ethan


I see nothing in this code but you really should do some more debugging. 
 Add some echos all around in your script so you can see where the 
blank lines are coming from.  Come on - we can't do your work for you - 
you have to be creative and find a way to isolate and identify your problem.


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



[PHP-DB] Re: Formatting

2012-11-25 Thread Jim Giner

On 11/25/2012 12:46 PM, Ethan Rosenberg, PhD wrote:

Dear list -

When I run the following code, the results are preceded by at least one
screen full of blank lines. I am showing you a large code block since I
do not know where the error is:

 if(isset($_REQUEST['Sex'])&& trim($_POST['Sex']) != '' )
 {
 if ($_REQUEST['Sex'] === "0")
 {
 $sex = 'Male';
 }

 else
 {
 $sex = 'Female';
 }

  }
 $allowed_fields = array
 ('Site' => 's',  'MedRec' => 'i', 'Fname' => 's',
'Lname' => 's','Phone'=> 's',   'Height' => 'i',   'Sex' => 's',
 'Hx' => 's','Bday' => 's',  'Age' => 'i'
 );

 if(empty($allowed_fields))
 {
  echo "ouch";
 }

 // Configure the query and the acceptable params to put
into the WHERE clause
 $sql12 = 'SELECT * FROM Intake3 WHERE 1';

// Magically put everything together
 $types = '';
 $args = array();
 foreach( $allowed_fields as $k => $type )
 {
  if( !array_key_exists( $k, $allowed_fields ) )
 continue;
 else
 {
 if( ($_POST[$k]) != '')
 {
 $args[] = &$_POST[$k]; // Note the addition of
the ampersand here
 $types .= $type;
 $sql12 .= " AND ($k = ?)";
 }
 }
 }
 $stmt = mysqli_stmt_init($cxn);
 mysqli_stmt_prepare( $stmt, $sql12 );

 if( !$stmt )
 throw new Exception( 'Error preparing statement' );

 // Put the statement and types variables at the front of
the params to pass to mysqli_stmt_bind_param()
 array_unshift( $args, $stmt, $types ); // Note that I've
moved this call. Apparently it doesn't pass back the result. I guess
sometimes I just forget these things.

 // mysqli_stmt_bind_param()
 if( !call_user_func_array( 'mysqli_stmt_bind_param', $args ) )
 throw new Exception( 'Failed calling
mysqli_stmt_bind_param' );

 if( !mysqli_stmt_execute( $stmt ) )
 throw new Exception( 'Error while executing statement' );

 mysqli_stmt_bind_result( $stmt,  $Site, $MedRec, $Fname,
$Lname, $Phone, $Height, $Sex, $Hx, $Bday, $Age);




 if(count($errors_array) == 0)
 {


?>
Search Results





Site
Medical Record
First Name
Last Name
Phone
Height
Sex
History
Birthday
Age



\n";
 $_SESSION['exe'] = 2;
?>
  
  
  
  
  
  
  

  
  
\n";
 $i = $i +1;

 }
 } while (mysqli_stmt_fetch($stmt)); //end do-while
 $imax = $i;
 echo "";
 echo "";
 echo "";

 }//end count($errors_array)

Help and advice, please

Ethan

If this is the ACTUAL code you are executing you need to remember to NOT 
include any blank lines.  Each and every one gets echoed to the client 
and with all the blank lines I see above, that could very well be a full 
but empty page.


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



[PHP-DB] Re: Program Dies

2012-10-15 Thread Jim Giner

On 10/14/2012 5:57 PM, Ethan Rosenberg, PhD wrote:

Dear List -

Thank you ever so much for all your help.

I apologize in advance for dumping all this code on you.  I cannot
get any debugger to work for me [see my separate email on debuggers].
I placed numerous echo and print_r statements in the code, and could
not find the error.

The program worked perfectly previously, and now it dies.

It mimic a doctor's office where a study is being performed on
obesity. The parameter is a calculated value called BMI.

In the initial part of the program, a search is performed to obtain
the medical record .  This works perfectly.  The second step is to
obtain data at the patient visit, which is triggered by a button "Do
you wish to enter visit data?"  If that button is clicked, the
program returns to the original welcome screen.

Advice and help, please.

Here is the code:

Ethan - If this is the code you are referring to, then I have some 
questions about it - some of them pertinent, some of them impertinent.
1 - do you plan on putting all of your input tags in their own div tags? 
 Kinda needless imho.
2 - if this is the form holding the button that you referred to in your 
post, why is there no action specified?  I've never tried code like that 
so I don't even know where one would end up in such a case.


Lastly - Why the  coding?  If you are going to show us 
what you are doing - at least have the sense to clean up the this kind 
of silly stuff to show us that you know what you are doing.


Do you Wish to Enter Visit Data? 

YesNo

<

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



[PHP-DB] Re: Prepared Statements - Select - Bind Parameters w/ correction

2012-09-27 Thread Jim Giner

On 9/27/2012 12:40 PM, Ethan Rosenberg, PhD wrote:

Dear list -

SEE CORRECTION IN $_POST VARIABLE BELOW.

Thanks to all for your help.

I hope [??] that this question will solve all the remaining problems.

So that we are on the same page, here is what was previously stated.

mysqli_stmt_bind_param expects three variables, in this order 
mysqli_stmt_bind_param($stmt, "num", $a, $b, $c)
 Where stmt is the query w/ the ?? that is

SELECT Site, MedRec, Fname, Lname, Phone, Height, Sex, Hx, Bday, Age
FROM Intake3 where  1  AND (Site  = ?)  AND (MedRec  = ?)  AND (Sex  = ?)
  and num is the number and  type of variables is the query, in this
case 'sis'

$a $b and $c are the variables to be inserted, in this case:
 $a = $_POST['Site'];
 $b = $_POST['MedRec'];
 $c = $_POST['Sex'];

As I seem to have found, the variables cannot be a string or components
of an imploded array.

This is a search function that will take patient supplied data and
search the Intake database to determine the Medical Record Number.
There are nine variables in the database, and I never know which
variables the patient will give.

Based on the database, it is easy to set up the correspondence.  The
database is searched in the order of the correspondence and the letters
can be
immediately determined...


$a = $_POST['Site']

$b = $_POST['MedRec']

$c = $_POST['Fname']

$d = $_POST['Lname']

$e = $_POST['Phone']

$f = $_POST[Height']

$g = $_POST['Sex']

$h = $_POST['Hx']

$i = $_POST['Bday']

$i = $_POST['Age']  <- Corrected


The challenge is to be able to dynamically select the variables that
will go intomysqli_stmt_bind_param.

Advice and help, please


Ethan
Sounds like you are asking for a solution to a "programming problem" and 
not a syntax/language problem.  If so, it would be better to see what 
YOU have already tried and ask for help in fixing or improving that.


We're not here to do your programming for you - just to help you with 
programming problems.  We all have situations such as this where we 
spend the time to Solve the problem.


At first glance, I'd have my html present a set of checkboxes tied to 
the arguments, and then display a new, customized screen to ask for and 
accept the input only for the checked fields.



And btw - is that example of your bind statment REALLY the code as it 
exists in your current script?  I think not.  Tsk, Tsk.



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



Re: [PHP-DB] opening error messages in a new window

2012-09-26 Thread Jim Giner

On 9/26/2012 9:35 AM, Jimi Thompson wrote:

So tell the error message to open in a target="_blank"

On Wed, Sep 26, 2012 at 3:41 AM, Dr Vijay Kumar <
vaibhavinformat...@gmail.com> wrote:


In filling a form, error messages should come in a new widow while
retaining the  form filled on the screen. Coding in php is required.

--


  Dr Vijay Kumar,
E 9/18 Vasant Vihar, New Delhi-110 057 Ph: 09868 11 5354, 011-2615 4488
Email :"Dr Vijay Kumar"







Since he seems to want to use PHP, his page would have to have that 
pre-coded in the form tag, eliminating the 'normal' path to his process, 
no?  Of course, JS could change it on the fly if he didn't want to do 
this with php.



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



[PHP-DB] Re: opening error messages in a new window

2012-09-26 Thread Jim Giner

On 9/26/2012 4:41 AM, Dr Vijay Kumar wrote:

In filling a form, error messages should come in a new widow while
retaining the  form filled on the screen. Coding in php is required.

If I read your rather terse message correctly, you are looking for a way 
to provide error responses to the user without losing his/her input.


One way would be to add JS to your page, but you want it done with php. 
To do that all you have to do is be sure to capture all the input fields 
before beginning your editing and then to be sure to use those captured 
values (in their php vars) as the value clause of the html tags.


When you are receiving the POST data:
$fld1 = $_POST['fld1'];
$fld2 = $_POST['fld2'];
.
.
.
When you are editing use a var to hold your error message:
$errmsg = '';
if ($fld1 == '')
{
   $errmsg .= "You must enter a value for ";
}
if ($fld2 > 0 && $fld2 < 10)
{
   $errmsg .= "You must enter a value between 1 and 9 for ";
}
When you prepare the output page with tags:

echo $errmsg;
echo "";
echo "";
echo "";
.
.
.

Hope this is what you are looking for, altho if you are already using 
php, you should already be doing this



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



[PHP-DB] Why the sudden dis-interest?

2012-09-21 Thread Jim Giner
What's with all the people suddenly wanting to unsubscribe?  Did they 
suddenly become experts - no longer needing the community for support? 
Or did they suddenly discover they had actually enlisted for the influx 
of emails they were getting and wanted to stop them?  Sure seems odd


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



[PHP-DB] Re: Many columns (as FK) vs 3x more Columns (in the same table)

2012-09-19 Thread Jim Giner

On 9/19/2012 3:12 PM, Jim Giner wrote:

On 9/18/2012 8:52 AM, Bruno Sandivilli wrote:

Hi, i strugling to decide what is the best choice:

I have a 15 row x 3 columns Flash DataGrid, it means, for each row i
have 3
values.
To represent this in my Database, I could:


1. Create 2 Tables : A Values table - with 3 columns ; and a Bill
table
(with 15 foreign keys, each one pointing to one row in the Values
table).
2. Create one Table with 45 columns (15 fields * 3 values for each
field).

I want to know, wich is the best choice?
To manage my query, now i have a SELECT with a thousand of leftJoins.

This is the best choice?

How could I run a query wich will give all results linked, like:
( column_1_val_1, column_1_val_2, column_1_val_2,
   column_2_val_1, column_1_val_2, column_1_val_3,
  etc...) ?

Thanks!


I don't get it either.

You have 15 rows with 3 cols each.  So?  Display them.  Query them.  Big
deal.

What is the real difficulty here?  I'm not seeing it.

(I don't read it as 15x3x3 - at least that's not what he said since he
said 'for each row he has 3 values')
Continuing on - why is your visual structure at this point NOT the same 
as your physical structure?  I don't think you're telling us what your 
real problem is here.  We need more information.  You have '15 row with 
3 cols each', ie, 'each row has 3 values'.  So - your table has 15 
records in it, each with 3 columns.  Add a key field to give each row an 
identity and that's it. No?


Sorry - but again - this post is not showing me a clear problem.

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



[PHP-DB] Re: Many columns (as FK) vs 3x more Columns (in the same table)

2012-09-19 Thread Jim Giner

On 9/18/2012 8:52 AM, Bruno Sandivilli wrote:

Hi, i strugling to decide what is the best choice:

I have a 15 row x 3 columns Flash DataGrid, it means, for each row i have 3
values.
To represent this in my Database, I could:


1. Create 2 Tables : A Values table - with 3 columns ; and a Bill table
(with 15 foreign keys, each one pointing to one row in the Values table).
2. Create one Table with 45 columns (15 fields * 3 values for each
field).

I want to know, wich is the best choice?
To manage my query, now i have a SELECT with a thousand of leftJoins.

This is the best choice?

How could I run a query wich will give all results linked, like:
( column_1_val_1, column_1_val_2, column_1_val_2,
   column_2_val_1, column_1_val_2, column_1_val_3,
  etc...) ?

Thanks!


I don't get it either.

You have 15 rows with 3 cols each.  So?  Display them.  Query them.  Big 
deal.


What is the real difficulty here?  I'm not seeing it.

(I don't read it as 15x3x3 - at least that's not what he said since he 
said 'for each row he has 3 values')


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



Re: [PHP-DB] Re: Problems w/ insert -- SOLVED!!!

2012-09-13 Thread Jim Giner

On 9/13/2012 9:15 PM, Ethan Rosenberg, PhD wrote:

Dear list -

Thanks to all.  It now works!

The problem, as you correctly noted, was the erroneous inclusion of the
bind-results statement.  Removed that and it  worked!!

Thanks again!

Ethan

Methinks Ethan is thanking the group for assistance on his PREVIOUS 
problem with the prepared INSERT query.


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



[PHP-DB] Re: Adding entry to /dev

2012-09-10 Thread Jim Giner

On 9/10/2012 7:41 PM, Ethan Rosenberg, PhD wrote:


Dear list -

How do I add a new entry to /dev; eg, /dev/sdb?

Thanks,

Ethan Rosenberg

Ethan,
Sometimes google is great at answering this kind of stuff.  Did you try 
a search on your question.  I did and found an answer in the fifth 
result returned.


Search on "php add a new subfolder"

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



Re: [PHP-DB] Re: Problems w/ insert

2012-09-10 Thread Jim Giner

On 9/11/2012 12:04 AM, Matt Pelmear wrote:

Ethan,

I am curious why you are using mysqli_stmt_bind_result() on a statement
that is an INSERT query? I don't use mysqli, but as I read the
documentation it seems to me that this method is intended to bind
results from a SELECT query into variables so that you can simply call
mysqli_stmt_fetch() in a loop and have the variables magically contain
the data from the next row.

Perhaps mysqli is confused because you are both mapping data to be bound
(with mysqli_stmt_bind_param()) and to be returned (with
mysqli_stmt_bind_result()) on the same INSERT query?

If you are just trying to insert, you should only need
mysqli_stmt_bind_param() (which, by my count, has one parameter too many
right now in your code) and mysqli_stmt_execute()   (and probably not
mysql_stmt_bind_param() and mysql_stmt_fetch()). See "Example #2" here:
http://us.php.net/manual/en/mysqli-stmt.execute.php

-Matt

On 09/10/2012 08:29 PM, Karl DeSaulniers wrote:


On Sep 10, 2012, at 7:06 PM, Ethan Rosenberg, PhD wrote:


Dear list -

 Here is my code:

$sql3 = "select max(Indx) from Visit3";
   $result7 = mysqli_query($cxn, $sql3);
   $row7 = mysqli_fetch_array($result7, MYSQLI_BOTH);

   $Indx = $row7[0];
   $sql2 =  "INSERT INTO Visit3(Indx, Site, MedRec, Notes,
Weight, BMI, Date) VALUES(?, ?, ?, ?, ?, ?, ? )";

   mysqli_stmt_prepare( $stmt, $sql2 );

   $_POST['Indx'] = $Indx;

   $_POST['Date'] = $Date;

   mysqli_stmt_bind_param($stmt, 'isisiis', $_POST['Indx'],
$_POST['Site'], $_POST['MedRec'],
   $_POST['Notes'], $_POST['Weight'], $_POST['BMI'],
$_POST['Date']);
   mysqli_execute($stmt);
   mysqli_stmt_bind_result($stmt, $_POST['Indx'],
$_POST['Site'], $_POST['MedRec'],  $_POST['Notes'],
   $_POST['Weight'], $_POST['BMI'], $_POST['Date']);
*//The error is in this statement*
  mysqli_stmt_fetch($stmt);
  mysqli_stmt_close($stmt);

*Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't
match number of fields in prepared statement*

*
*
Help and advice, please.

Ethan Rosenberg

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




Maybe right here there needs to be something?

mysqli_stmt_bind_result($stmt, ?, $_POST['Indx'], ...

in the statement above you have.

mysqli_stmt_bind_param($stmt, 'isisiis', $_POST['Indx'], ...

what ever 'isisiis' is, you need to put somehting in your
...bind_result() I think.
maybe..

mysqli_stmt_bind_result($stmt, '', $_POST['Indx'],

or

mysqli_stmt_bind_result($stmt, 'isisiis', $_POST['Indx'],

sorry for not a more concrete answer. I am guessing a little. :)
HTH,

Karl DeSaulniers
Design Drumm
http://designdrumm.com




If I had read further I would not have made my post a moment ago.  Give 
Matt here the credit for seeing the forest thru the trees.  :)


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



[PHP-DB] Re: Problems w/ insert

2012-09-10 Thread Jim Giner

On 9/10/2012 8:06 PM, Ethan Rosenberg, PhD wrote:

Dear list -

   Here is my code:

$sql3 = "select max(Indx) from Visit3";
 $result7 = mysqli_query($cxn, $sql3);
 $row7 = mysqli_fetch_array($result7, MYSQLI_BOTH);

 $Indx = $row7[0];
 $sql2 =  "INSERT INTO Visit3(Indx, Site, MedRec, Notes,
Weight, BMI, Date) VALUES(?, ?, ?, ?, ?, ?, ? )";

 mysqli_stmt_prepare( $stmt, $sql2 );

 $_POST['Indx'] = $Indx;

 $_POST['Date'] = $Date;

 mysqli_stmt_bind_param($stmt, 'isisiis', $_POST['Indx'],
$_POST['Site'], $_POST['MedRec'],
 $_POST['Notes'], $_POST['Weight'], $_POST['BMI'],
$_POST['Date']);
 mysqli_execute($stmt);
 mysqli_stmt_bind_result($stmt, $_POST['Indx'],
$_POST['Site'], $_POST['MedRec'],  $_POST['Notes'],
 $_POST['Weight'], $_POST['BMI'], $_POST['Date']);
*//The error is in this statement*
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);

*Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't
match number of fields in prepared statement*

*
*
Help and advice, please.

Ethan Rosenberg
Ethan - PS to my other response:  I think you should make a change to 
use the preferred syntax for the execute statement.  The one you are 
using is deprecated, so will be removed in the future.  May as well 
write code that isn't already on the way out.


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



Re: [PHP-DB] Re: Problems w/ insert

2012-09-10 Thread Jim Giner

On 9/10/2012 8:29 PM, Karl DeSaulniers wrote:


On Sep 10, 2012, at 7:06 PM, Ethan Rosenberg, PhD wrote:


Dear list -

 Here is my code:

$sql3 = "select max(Indx) from Visit3";
   $result7 = mysqli_query($cxn, $sql3);
   $row7 = mysqli_fetch_array($result7, MYSQLI_BOTH);

   $Indx = $row7[0];
   $sql2 =  "INSERT INTO Visit3(Indx, Site, MedRec, Notes,
Weight, BMI, Date) VALUES(?, ?, ?, ?, ?, ?, ? )";

   mysqli_stmt_prepare( $stmt, $sql2 );

   $_POST['Indx'] = $Indx;

   $_POST['Date'] = $Date;

   mysqli_stmt_bind_param($stmt, 'isisiis', $_POST['Indx'],
$_POST['Site'], $_POST['MedRec'],
   $_POST['Notes'], $_POST['Weight'], $_POST['BMI'],
$_POST['Date']);
   mysqli_execute($stmt);
   mysqli_stmt_bind_result($stmt, $_POST['Indx'],
$_POST['Site'], $_POST['MedRec'],  $_POST['Notes'],
   $_POST['Weight'], $_POST['BMI'], $_POST['Date']);
*//The error is in this statement*
  mysqli_stmt_fetch($stmt);
  mysqli_stmt_close($stmt);

*Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't
match number of fields in prepared statement*

*
*
Help and advice, please.

Ethan Rosenberg

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




Maybe right here there needs to be something?

mysqli_stmt_bind_result($stmt, ?, $_POST['Indx'], ...

in the statement above you have.

mysqli_stmt_bind_param($stmt, 'isisiis', $_POST['Indx'], ...

what ever 'isisiis' is, you need to put somehting in your
...bind_result() I think.
maybe..

mysqli_stmt_bind_result($stmt, '', $_POST['Indx'],

or

mysqli_stmt_bind_result($stmt, 'isisiis', $_POST['Indx'],

sorry for not a more concrete answer. I am guessing a little. :)
HTH,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


Ethan,
This is almost the exact same problem you posted last week and we were 
unable to solve it then.


Having said that I think I suddenly see it.  An "INSERT" query does not 
return any 'result', as I believe the intent of the 'bind-result' call 
is designed for.  If you were doing a SELECT to pull those fields from 
the table this would work I'm guessing.  But since it is an INSERT, 
there are no fields to be bound.  That is the error!




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



Re: [PHP-DB] Another PDO ?

2012-09-10 Thread Jim Giner

On 9/10/2012 11:10 AM, Lester Caine wrote:

Jim Giner wrote:

On 9/10/2012 10:49 AM, Bastien Koert wrote:

On Mon, Sep 10, 2012 at 9:48 AM, Jim Giner
 wrote:

Reading up on the pdostatement class.  Wondering what the intent of the
columnCount function is.  I mean, aren't the number of columns in a
result
known when you write the query?  Granted, you might have some very
complex
query that you may not know the number, but for most queries you
will know
the columns you are expecting.  So - what am I not seeing?

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



It might be for those cases where you run a select * from ...


But - again - one already knows how many fields are in that table when
one
writes the query...


You do not necessarily KNOW how many fields. You know how many fields
should be in the version of the database you are coding for, so any
difference would flag a problem. Also you may not ACTUALLY have the
schema for a database in which case a count of the fields found is
useful for further processing those fields.

Another area is when you are working with fabricated joined queries
where duplicate field names between tables will give a reduced number of
final fields in the result.

Of cause it IS often better to work with named fields rather than using
'*' which does allow better handing of the process anyway.

I find it difficult to fathom a scenario where I am able to write 
queries against a db but not have access to the layouts.  Makes it kind 
of hard to know what I'm going to get back  but I guess it must 
occur somewhere since someone decided this function was necessary.


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



Re: [PHP-DB] Another PDO ?

2012-09-10 Thread Jim Giner

On 9/10/2012 10:53 AM, Graham H. wrote:

I think it's so that you could write functions as generically as possible.
So you don't have to pass in the number of columns or hard code in values
for number of columns, you can dynamically check the column count for each
result set that gets passed in. That's my guess.

On Mon, Sep 10, 2012 at 8:51 AM, Jim Giner wrote:


On 9/10/2012 10:49 AM, Bastien Koert wrote:


On Mon, Sep 10, 2012 at 9:48 AM, Jim Giner 
wrote:


Reading up on the pdostatement class.  Wondering what the intent of the
columnCount function is.  I mean, aren't the number of columns in a
result
known when you write the query?  Granted, you might have some very
complex
query that you may not know the number, but for most queries you will
know
the columns you are expecting.  So - what am I not seeing?

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



It might be for those cases where you run a select * from ...

  But - again - one already knows how many fields are in that table when

one writes the query...


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





I have not yet had a design where the results of queries could be 
handled generically.  Yes I may save some coding time in one way, but 
for each field in a result the handling is not usually the same, 
therefore my code would have to specify unique field names at some 
point.  This would only apply to a query that used * instead of distinct 
names too.


To me it seems a function with rather limited use.

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



Re: [PHP-DB] Another PDO ?

2012-09-10 Thread Jim Giner

On 9/10/2012 10:49 AM, Bastien Koert wrote:

On Mon, Sep 10, 2012 at 9:48 AM, Jim Giner  wrote:

Reading up on the pdostatement class.  Wondering what the intent of the
columnCount function is.  I mean, aren't the number of columns in a result
known when you write the query?  Granted, you might have some very complex
query that you may not know the number, but for most queries you will know
the columns you are expecting.  So - what am I not seeing?

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



It might be for those cases where you run a select * from ...

But - again - one already knows how many fields are in that table when 
one writes the query...


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



[PHP-DB] Re: PDO user question

2012-09-10 Thread Jim Giner

On 9/8/2012 2:02 PM, Jim Giner wrote:

I finally delved into learning how I was going to replace my MYSQL calls
with a different interface.  Had to go with PDO since my hoster doesn't
support MYSQLI for my plan.

I've had some success with querying using pdo and prepared statements as
well.  One thing that I'm curious about is

How does one handle the need to get the number of rows returned by a
Select?  The documentation is very clear that PDO doesn't return that
value for a Select statement (depending upon driver?) and there were a
couple of solutions that made no sense to me.  There was even one that
did a completely separate query just to get the row count which makes
even less sense.

Will PDO ever come up with an accurate row count function?
Does someone have a tried and true snippet they can share?


For those looking for the answer to my question also, I've learne dthat 
this will work for 'small' result sets.  My applications do not make 
requests for large result sets, so this works fine.


$rows = $qrslts->fetchAll(PDO::FETCH_ASSOC);
echo count($rows)." results found";

I suppose if I ever write up a new appl that will have to handle large 
query results, I'll have to come up with something else.


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



[PHP-DB] Another PDO ?

2012-09-10 Thread Jim Giner
Reading up on the pdostatement class.  Wondering what the intent of the 
columnCount function is.  I mean, aren't the number of columns in a 
result known when you write the query?  Granted, you might have some 
very complex query that you may not know the number, but for most 
queries you will know the columns you are expecting.  So - what am I not 
seeing?


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



[PHP-DB] PDO user question

2012-09-08 Thread Jim Giner
I finally delved into learning how I was going to replace my MYSQL calls 
with a different interface.  Had to go with PDO since my hoster doesn't 
support MYSQLI for my plan.


I've had some success with querying using pdo and prepared statements as 
well.  One thing that I'm curious about is


How does one handle the need to get the number of rows returned by a 
Select?  The documentation is very clear that PDO doesn't return that 
value for a Select statement (depending upon driver?) and there were a 
couple of solutions that made no sense to me.  There was even one that 
did a completely separate query just to get the row count which makes 
even less sense.


Will PDO ever come up with an accurate row count function?
Does someone have a tried and true snippet they can share?

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



Re: [PHP-DB] mysqli_connect ??

2012-09-07 Thread Jim Giner

No - they are not.  :(
On 9/7/2012 1:32 PM, Bastien Koert wrote:

On Fri, Sep 7, 2012 at 10:54 AM, Jim Giner  wrote:

Experimenting with prepared statements - trying out for the first time.

I keep getting a fatal error on this statement:

mysqli_connect(.)

Message is:
Fatal error: Call to undefined function mysqli_connect() in
/home/albany/php/sqli_db_connect_select.php on line 6

My host is running php 5.3.9

Can anyone clue me in?  I copied my usage directly from the manual!

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


Check to see if mysqli_functions are enabled with phpinfo()




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



[PHP-DB] mysqli_connect ??

2012-09-07 Thread Jim Giner

Experimenting with prepared statements - trying out for the first time.

I keep getting a fatal error on this statement:

mysqli_connect(.)

Message is:
Fatal error: Call to undefined function mysqli_connect() in 
/home/albany/php/sqli_db_connect_select.php on line 6


My host is running php 5.3.9

Can anyone clue me in?  I copied my usage directly from the manual!

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



Re: [PHP-DB] Re: Prepared Statements Insert Problem

2012-09-03 Thread Jim Giner

On 9/3/2012 2:44 AM, tamouse mailing lists wrote:

On Sun, Sep 2, 2012 at 10:24 PM, Ethan Rosenberg, PhD
 wrote:

mysqli_stmt_bind_result(): Number of bind variables doesn't match number of
fields in prepared statement


What exactly is unclear about that?

Actually - from looking at the code the OP posted, I don't see the 
mis-match either, assuming that the post contains the actual code.  I do 
have a question tho.  Not being familiar with mysqli yet (soon, I know), 
I'm wondering what his die clause is actually saying when it mentions:

... mysqli_stmt($stmt)

Does the reference to 'mysqli_stmt' mean something special, since it 
doesn't reference any particular function?


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



Re: [PHP-DB] Re: Prepared Statements Insert Problem

2012-09-02 Thread Jim Giner
So do u have the revised code to show us?


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



[PHP-DB] Re: Prepared Statements Insert Problem

2012-09-02 Thread Jim Giner

On 9/2/2012 12:45 AM, Ethan Rosenberg, PhD wrote:

Dear List -

I wish to accomplish the following with prepared statements:

FYI -

The Database:

mysql> describe Intake3;
++-+--+-+-+---+
| Field  | Type| Null | Key | Default | Extra |
++-+--+-+-+---+
| Site   | varchar(6)  | NO   | PRI | |   |
| MedRec | int(6)  | NO   | PRI | NULL|   |
| Fname  | varchar(15) | YES  | | NULL|   |
| Lname  | varchar(30) | YES  | | NULL|   |
| Phone  | varchar(30) | YES  | | NULL|   |
| Height | int(4)  | YES  | | NULL|   |
| Sex| char(7) | YES  | | NULL|   |
| Hx | text| YES  | | NULL|   |
| Bday   | date| YES  | | NULL|   |
| Age| int(3)  | YES  | | NULL|   |
++-+--+-+-+---+

The connection to the database was successful

The variables:

$fptr1 = fopen("/home/ethan/PHP/HRecnumSite", "r+");
fscanf($fptr1,"%d %s",$MedRec, $Site);

$_POST['MedRec'] = $MedRec;
$_POST['Site'] = $Site;
$fname = $_POST['Fname'];
$lname = $_POST['Lname'];
$phone = $_POST['Phone'];
$hgt   = $_POST['Height'];
$sx= $_POST['Sex'];
$hx= $_POST['Hx'];
$bday  = $_POST['Bday'];
$age   = $_POST['Age'];
if($sx==1)$_POST['Sex'] = 'F';
if($sx==0)$_POST['Sex'] = 'M';

Statement to convert:

$sql1 =  "INSERT INTO Intake3(Site, MedRec, Fname, Lname, Phone, Height,
Sex, Hx, Bday, Age)
VALUES('$Site', $MedRec, '$fname', '$lname', '$phone', $hgt, '$sx',
'$hx', '$bday', '$age')";

My attempt [which failed]

   $stmt = mysqli_stmt_init($cxn);
  if($stmt = mysqli_stmt_prepare($stmt, "INSERT INTO Intake3 (Site,
MedRec, Fname, Lname, Phone, Height, Sex, Hx, Bday, Age)
VALUES(?,?,?,?,?,?,?,?,?,?")!=0)
 {
 print_r($stmt);
 mysqli_stmt_bind_param($stmt, 'sisssisssi', $Site, $MedRec, $fname,
$lname, $phone, $hgt, $sx, $hx, $bday, $age);
 mysqli_execute($stmt);
 mysqli_stmt_bind_result($stmt, $Site, $MedRec, $fname, $lname,
$phone, $hgt, $sx, $hx, $bday, $age);
 echo $stmt;
 mysqli_stmt_fetch($stmt);
 mysqli_stmt_close($stmt);
 }
  else
  echo "Ouch";

Regrettably, all I see on the monitor is "ouch"!!

Help and advice, please.

Ethan Rosenberg





So - no error.  Does that mean it now works?

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



Re: [PHP-DB] Re: No data?

2012-07-27 Thread Jim Giner

On 7/27/2012 11:03 AM, Brad wrote:

Even though my permissions are 777 in my /tmp I am trying to send the file
to a tmp directory in my webroot and if I can even get it to create the file
it has the wrong name of 'Array', and then it still does not update my
database.




 0)
 {
 echo "Return Code: " . $inFile['error'] . "";
 }
 else
 {
 dbConnect();
 //move_uploaded_file($_FILES["file"],$target_path);
 move_uploaded_file($inFile["file"]["tmp_name"],
$target_path .'/'.$inFile);
 //chmod ($filename['file'], 0777);
 mysql_select_db('mailList') or die(mysql_error());
 //assign temporary name to variable
 //for insert since tmp_file is the real file
 //$tmp_name =  $inFile["file"];
 $presql = "CREATE TABLE IF NOT EXISTS `{$memberID}`
(id MEDIUMINT AUTO_INCREMENT PRIMARY KEY UNIQUE)";
 $midsql = "ALTER TABLE `{$memberID}` ADD
`{$filename}` VARCHAR(60)";
 $sql = <<



*



array(1) { ["file"]=> array(5) { ["name"]=> string(13) "testBook1.csv"
["type"]=> string(24) "application/octet-stream" ["tmp_name"]=> string(14)
"/tmp/phpZVJWhW" ["error"]=> int(0) ["size"]=> int(102) } } array(1) {
["file"]=> array(5) { ["name"]=> string(13) "testBook1.csv" ["type"]=>
string(24) "application/octet-stream" ["tmp_name"]=> string(14)
"/tmp/phpZVJWhW" ["error"]=> int(0) ["size"]=> int(102) } }
Notice: Undefined index: file in /home/nyctelecomm.com/www/mail/import.php
on line 29
string(169) "   LOAD DATA LOCAL INFILE 'Array' INTO TABLE `3` FIELDS
TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY "\r\n
IGNORE 1 LINES (testBook1)"" $sqlFile 'Array' not found (Errcode: 2)



-Original Message-
From: Tamara Temple [mailto:tamo...@gmail.com]
Sent: Friday, July 27, 2012 10:46 AM
To: Brad
Cc: 'tamouse mailing lists'; php-db@lists.php.net
Subject: Re: [PHP-DB] Re: No data?

Brad  wrote:


Wow, this is unbeileivable. Your test script fails with the attached csv

where column `a` in blank too!

No, with your attached file, it works:

array(2) {
   [0]=>
   string(15) "br...@yahoo.com"
   [1]=>
   string(1) "1"
}
array(2) {
   [0]=>
   string(15) "br...@yahoo.com"
   [1]=>
   string(1) "2"
}
array(2) {
   [0]=>
   string(15) "br...@yahoo.com"
   [1]=>
   string(1) "3"
}
array(2) {
   [0]=>
   string(15) "br...@yahoo.com"
   [1]=>
   string(1) "4"
}
array(2) {
   [0]=>
   string(15) "br...@yahoo.com"
   [1]=>
   string(1) "5"
}
array(2) {
   [0]=>
   string(15) "br...@yahoo.com"
   [1]=>
   string(1) "6"
}

You seem to be very stubborn in your attempts to handle this problem. 
All the suggestions we have provided you seem to be ignoring.  Dont' 
understand your mentality and I surely hope you are not exhausting your 
employer's resources on this effort.


Once again - upload the file and move it and name it.  Then never 
reference $_FILES again.


In particular - in your latest posting here you appear to have misused 
the $infile var in your DATA LOAD  statement.  See how confusing you 
make this for yourself?


Leave me off any future emails.  I have lost interest.  :(

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



Re: [PHP-DB] Re: No data?

2012-07-26 Thread Jim Giner
Not sure what you mean - "Program reads array".  What program is doing 
is utilizing the FILES element to get the info about the uploaded file 
and proceeds to finish the upload by moving it to a temporary folder of 
your creation.  Once that is done you HAVE the file under whatever name 
you want to call it in whatever folder you want it in.


Why don't you just do that part and then use some tool to look at your 
server structure to verify that you have the file.


NOW you can proceed with the rest, if you must.  You're going to create 
a table with a column/field name matching the filename and then you'll 
put the contents of that file into that single column in one record of 
this table.  So now you have a one record table with one column holding 
the contents of a file.  How is this different from just having the file?


1 User uploads file
2 program reads array
3 program creates a table called $memberID.$filename  if not exist
($filename is column)
4 program uploads data into table/column

I am messed up at #2 for some reason so #4 fails.



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



[PHP-DB] Re: No data?

2012-07-26 Thread Jim Giner
Are you any closer to getting your solution to work yet?  If not, could 
I ask for the general concept again?  From what I can remember, You want 
to allow a user to upload a csv file which you will then put into a sql 
table.  Additionally your code seems to be creating a new table for each 
file uploaded.  Are these csv files each unique, ie, do they have 
different data contents as in different "fields" of information?  Or do 
they all supply the same information in the same format.  ( Hope you get 
what I mean.)  If each file is different and each table is going to have 
different column names, how are these tables then going to be processed? 
You'll need different handlers for each table, no?  And if each file is 
the same then why not put the data into separate records of the same table?


As I mentioned before - it sure seems like you are trying to do too many 
things at once.  Concentrate on getting the client file onto the server 
with a unique name and THEN work on the next problem of putting it into 
a table if you must.


And if I am just entirely off-base, tell me to buzz off and I will leave 
this thread alone.  I just hate to see someone struggling for so many 
days on something that seems so simple to me.


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



Re: [PHP-DB] Re: Stuck trying to upload and grab file name

2012-07-24 Thread Jim Giner

On 7/24/2012 12:40 PM, Graham H. wrote:

If by "the line" you mean:   ["tmp_name"]=> string(14) "/tmp/phpcLtE6W"

That is from the bottom of this Pastie link: http://pastie.org/4317155



$file = $_FILES["file"]["tmp_name"];



I meant the above line.

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



[PHP-DB] Re: Stuck trying to upload and grab file name

2012-07-24 Thread Jim Giner

On 7/24/2012 4:16 AM, Brad wrote:

 $file = $_FILES['file']['name'];

 //$presql = "CREATE TABLE IF NOT EXISTS
(`$_SESSION[SESS_MEMBER_ID]_$file`)";

 $presql = "CREATE TABLE IF NOT EXISTS
`$_SESSION[SESS_MEMBER_ID]_$file`";

 $sql = <<
Brad,
Since you have defined a var $file containing what you need, why don't 
you use that var in your LOAD DATA line, instead of the convoluted 
$_FILES reference?


If I may ask, what does the reference to $_SESSION[SESS_MEMBER_ID] 
accomplish?  Haven' had an occasion to do this.


I'm also wondering if the error you are receiving has anything to do 
with the name.  It may be the syntax using those slashes as delimiter chars.


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



Re: [PHP-DB] Re: Stuck trying to upload and grab file name

2012-07-24 Thread Jim Giner


On 7/24/2012 12:05 PM, Graham H. wrote:

Does the problem have anything to do with this:


  ["tmp_name"]=> string(14) "/tmp/phpcLtE6W"

So this:

$file = $_FILES["file"]["tmp_name"];

Would make $file == "/tmp/phpcLtE6W"

I'm not sure if that's what you want. Seems more likely that you'd want it
to be:

$file = $_FILES["file"]["name"];

Useful?



Graham,
The line you reference - I don't see that in my code (which is 
production code) nor in the OP's code.


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



  1   2   >