Re: [PHP-DB] Submitting form from a href

2006-07-14 Thread Andrew Kreps

Skip,

Just so you know, there is a general PHP user's list available for
just such a request.  It's rather high-traffic, so be warned.

Now then, on to the problem.  I believe I've figured out a way to make
this happen.  I've only tested it on IE 6 and Firefox 1.5.0.4, so your
browser compatibility may vary.  I'll just post the scripts I used to
test it here and you can take what you need and run with it.

Here is the script that my form is built in:

--

html
head
script language=Javascript
function submitForm (letter)
{
document.search.letter.value = letter;// 
Here's where we're
setting the form value 'letter' to the letter the user clicked on.
document.search.submit();   // Then, submit the 
form.
}
/script
/head
body
form name=search method=POST 
action=testingLinkSubmit.php
input type=hidden name=letter value=  !-- If 
this isn't
here, the Javascript letter.value code won't work, since form.letter
doesn't exist.  --
input type=checkbox name=checky/ Search all 
campuses
br

?
for ($i = 65;  $i = 90;  $i++)
{
$letter = chr($i);
print a 
href=\javascript:submitForm('$letter')\$letter/a ;
}
?
/form
/body
/html

-

The receiving end of the form looks much as you might expect, it just
parses the form values:

--

html
body
?
if (isset($_POST[checky]))
{
print Checkbox value is: Truebr\n;
}
else
{
print Checkbox value is: Falsebr\n;
}

print Letter:  . $_POST[letter];
?
/body
/html



And there you go!  Let me know if you have any problems.



On 7/14/06, Skip Evans [EMAIL PROTECTED] wrote:

Hey all,

This is not database related, but I get the
impression this list entertains general PHP
questions? If I'm mistaken, flame away.

I need submit a form when a hyper link is pressed,
and have been trying all manner of onlicks, etc,
but have been unable to hit the right combination.

Here's the scenario:

I have the alphabet in hyper links with a check
box below:


form...
A B C D E F G H I J K.

[] check for all campuses
/form

What needs to happen is that when they click a
letter, which is a a href=... now, it submits
the check box value as well, to be read through
$_POST on the receiving end.

And of course I need to know what letter was
click, this I was trying to get through a
$_REQUEST var, but was not able to do so.

Any tips would be monstrously appreciated.
--
Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
406-782-2240

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




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



Re: [PHP-DB] PHP connect to mysql problem

2005-01-06 Thread Andrew Kreps
On Wed, 5 Jan 2005 15:25:21 +0300, Tsegaye Woldegebriel
[EMAIL PROTECTED] wrote:
 Anybody help!
 I can't connect from my PHP to mysql using the following code:
 $link = mysql_connect(localhost, root, merkato)
or die(Could not connect :  . mysql_error());
 it replies with error:
 Could not connect : Client does not support authentication protocol
 requested by server; consider upgrading MySQL client
 

It sounds like you're using the MySQL 3.x or 4.0 client to try to
connect to a 4.1 MySQL server.  MySQL 4.1 uses a different password
encryption (as you found), and you should update the PHP MySQL client
library to make it work.  You can also change the password encryption
on the MySQL server to make this work, although you'd be defeating a
security measure in doing so.  Have a look here:

http://dev.mysql.com/doc/mysql/en/Old_client.html

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



Re: [PHP-DB] MySQL Auto PK

2005-01-06 Thread Andrew Kreps
On Wed, 05 Jan 2005 18:11:23 -0500, John Holmes
[EMAIL PROTECTED] wrote:
 OOzy Pal wrote:
  Is it possible to have mysql at an ID as 20050105-1 as
  (MMDD-1), -2, etc.
 
 automatically? No. But you can always just use
 
 SELECT CONCAT(date_column,'-',pk_column) AS fixed_id ...
 
 if you _really_ need something like this. Or just join them together in
 PHP.

I think the only downside to that solution is that the primary key
will continue to increment regardless of the day, and I think the
original poster wanted:

20050105-1
20050105-2
20050106-1
...etc.

This would be a great place for a stored procedure, but I don't know
if I can recommend running MySQL 5 to you.  The most platform-safe way
I can think of is to get a count(*) of the number of rows with today's
date, add 1 to it, and stick that number on the end of the string
you've created to insert into a varchar field.  It's an extra query
per insert, but it'd do the job.

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



Re: [PHP-DB] Update / Delete / Insert quandry

2005-01-06 Thread Andrew Kreps
On Thu, 6 Jan 2005 07:28:32 -0800 (PST), Stuart Felenstein
[EMAIL PROTECTED] wrote:
 
 The problem I'm having a hard time getting my hands
 around are those areas where they can have multiple
 entries.
 
 One of the tables allows for a user to enter up to 5
 choices. The table would look like this:
 

I think you need to have a primary key that's unique per record.  That
would allow you to make modifications per record without worrying
about the duplicated RecordID.

As far as updates and additions go, I usually keep the two separate
when designing applications.  Being able to update multiple rows at
once shouldn't be a problem, you just select all the data, display it
to your users with the appropriate form elements (select boxes, check
boxes and such), and index it in your form by the unique id field.

I don't think it's necessary to delete the records and reload them,
doing that adds database load and increases the chance that something
will go wrong.  I hope I've touched on the items that concern you,
feel free to write back if you need more information.

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



Re: [PHP-DB] select text from a text file

2005-01-06 Thread Andrew Kreps
On Wed, 5 Jan 2005 11:58:59 -, Ed [EMAIL PROTECTED] wrote:
 Happy new year folks!
 
 The titlemight make this seem like an easy to answer question
 
 However here's the complicated bit (well for me anyway).
 
 In my text file that is written to by the users in a chatroom it looks like 
 this:
 
 nickname||color||what the user is saying||user
 
 how can i make it so that if they have a private message when they press 
 update it pulls the message from the text file and displays it in the frame 
 but also deletes the text?
 

You should be using a database for this, it makes things so much
easier.  That being said, here's one way to go about the text file
version:

Open the file, read through it line by line.
As you read it, push the lines into an array.
If you find a private message for the user, store that in a variable,
and do not push it into the array.
Finish reading the file.
If there's a private message, you've got it in a variable, and you can
overwrite the private message file with the array you've stored, which
is all of the current private messages minus the one you're about to
display.

Please note, this does not scale at all, especially in the fast-paced
world of chat rooms.  You will likely end up with file locking
problems if you proceed with the flat-file method.


 Also, how can i make it so that if in a drop down menu they select the word 
 everybody it goes to a file called messages.txt and if they select user 
 or user2 or user3 from the list it writes to private.txt is this at all 
 possible? user and user2 etc arent hardcoded it's pulling the names from a 
 list of online users.
 

Are you talking about appending messages to a text file?  In that
case, you can have the dropdown submit with the message, and in the
PHP code have a case for 'everybody' where it writes to messages.txt,
and if it's not 'everybody', write it to private.txt with the username
that was selected from the dropdown as part of the row.

Does that answer your question?

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



Re: [PHP-DB] Loading large volumes of data

2004-10-07 Thread Andrew Kreps
On Thu, 7 Oct 2004 09:05:55 +0200, Evan Morris
[EMAIL PROTECTED] wrote:
 I have a text file containing strings. The text file is pretty massive,
 about 895 MB. I need to load the words in the text file into the database in
 such a way that there is a single occurrence of each word in the table. 

I'm glad you found that the indexes worked for you.  I was curious if
your file already had one word per line?  If so, you could do a cat |
sort | uniq to pre-process the file and rid yourself of any duplicates
to eliminate the need for the check altogether.

I think that getting the data into a ready-to-load format before
involving the database would be quicker overall.   Not to disparage
PHP, but I would use Perl for such an endeavor.  PHP seems to have a
lot of memory overhead associated with text parsing.

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



Re: [PHP-DB] Obfuscator

2004-10-07 Thread Andrew Kreps
On Thu, 07 Oct 2004 09:10:16 -0400, Bastien Koert [EMAIL PROTECTED] wrote:
 Whats the point? Security thru obfuscation is not security at all. If you
 deem your site/data that sensitive, upgrade to ssl , lock the db down tight
 and pray that the sys admins at your host are on top of exploits and hacks
 to keep the server safe.

I think of obfuscation as more of a way to protect your intellectual
property.  It can help impede clients from taking your code (which you
own, you merely sold the implementation) and using it for their own
purposes, potentially cheating you out of a future contract.  For
those who live off of freelance projects, obfuscation can simply be a
little peace of mind.

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



Re: [PHP-DB] Database Backup

2004-10-06 Thread Andrew Kreps
On Wed, 6 Oct 2004 15:31:34 -0400, Aaron Todd [EMAIL PROTECTED] wrote:
  Do you happen to know
 how I might be able to push a file to another server using FTP?

I might http://us4.php.net/ftp  has a list of all the FTP related
PHP functions with some ready-to-use examples.  Enjoy!

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



Re: [PHP-DB] accessing two databases within one script

2004-10-05 Thread Andrew Kreps
On Mon, 04 Oct 2004 22:31:15 -0400, Gary Rachel [EMAIL PROTECTED] wrote:
 I've tried not using the mysql_close statement.  But that option doesn't
 select the new database, it seems to stay connected to the previous one,
 despite my specifying a new database to access.  Can I not access two
 databases within the same script?

I'm assuming that you're using localhost in both mysql_connect
statements.  You may want to try using the new_link option of the
mysql_connect function.  PHP might be trying to use your old (and
disconnected) link when you make your second connect call.  Have a
look at the function call docs for details on using that option.

http://us4.php.net/mysql_connect

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



Re: [PHP-DB] Auto-increment questions...

2004-10-05 Thread Andrew Kreps
On Tue, 5 Oct 2004 12:59:55 -0500, NIPP, SCOTT V (SBCSI) [EMAIL PROTECTED] wrote:
 OK.  The problem is I don't want the next highest number.
 There are gaps in the UID sequence.  I need to find the next UNUSED
 number in the sequence which is rarely the highest number.

As far as I know, you'll have to write a little function to do that
for you.  I don't know of a built-in database function that does what
you require.  Assuming your application is PHP, Something such as this
might work (pardon the shorthand):

function getNextMissing () 
{
  $result = select id from the_table order by id;
  while (list ($id) = mysql_fetch)
  {
if (isset ($lastId)  ($lastId  $id - 1))
{
$returnVal = $lastId + 1;
 }
 $lastId = $id;  
  }
  return $returnVal;
}

You'll need to modify the function to handle there being no gaps in
the sequence (i.e. return $id + 1 if you never hit the logic in the
if), or for that matter, there being no id's.  Otherwise, I think it's
a good starting point.  Good luck!

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



Re: [PHP-DB] Auto-increment questions...

2004-10-05 Thread Andrew Kreps
On Tue, 5 Oct 2004 14:18:55 -0700, Andrew Kreps [EMAIL PROTECTED] wrote:
 if (isset ($lastId)  ($lastId  $id - 1))
 {
 $returnVal = $lastId + 1;
  }

Sorry, I left a bit of a bug in there.  You should exit the loop at
this point, if you've found a gap.

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



Re: [PHP-DB] Unusual Array Results

2004-10-05 Thread Andrew Kreps
On Tue, 5 Oct 2004 13:49:11 -0700, Wendell Frohwein
[EMAIL PROTECTED] wrote:
 Hello all again, I am using php 5.0.1 with mysql 4.1.4a-gamma. After I
 did this upgrade, I noticed pieced of my code were failing. Took me a
 while to figure it out. When I would be working with arrays, sometimes I
 would call the values out like so:
 
 $value=$thearray[0];
 
 Every piece of script where I refer to the value like this has failed.
 So I ran a print_r() function to see what the output is. This is what I
 got:
 
 Array ( [] = 90606 [1] = 90610 [2] = 90660 [3] = 90661 [4] = 90662
 [5] = 90665 )
 
 This is not a huge problem, I just have to use foreach() instead of
 for() in my loop. Took me a good while to figure this out.
 Could this be a glitch within php 5.0.1? If so, where could I report
 this?
 

How are you populating your array?  I just tried your code creating
the array as such:

$arr = array (90606, 90610, 90660, 90661, 90662);

and I got the desired result, which is a 0 indexed array.  I'm running
PHP 5.0.1 as well, so I don't think this is a bug with the
interpreter.  Can you post your array initialization code?

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



Re: [PHP-DB] Database Backup

2004-10-05 Thread Andrew Kreps
On Tue, 5 Oct 2004 16:33:08 -0400, Aaron Todd [EMAIL PROTECTED] wrote:
 What is everyone doing to backup a MySQL database.  Just in case...I'd like
 to backup mine, but I was wondering if there was a way to do it without
 going to a page and clicking a button.  Is there a way to run a php script
 on a time schedule and then push a backup file to an FTP server or
 something.  Anyone out there doing anything like this?

Personally, I go straight to the source.  

http://dev.mysql.com/doc/mysql/en/mysqldump.html

You can write a PHP script that runs the dump, compresses the file and
FTP's the file anywhere you like.  As Martin mentioned, You can run
this PHP script from your crontab or Task Scheduler by invoking the
interpreter from the command line, i.e. '/usr/local/bin/php
/home/mydir/scripts/backupDB.php'.

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



Re: [PHP-DB] Unusual Array Results

2004-10-05 Thread Andrew Kreps
On Tue, 5 Oct 2004 16:50:04 -0700, Wendell Frohwein
[EMAIL PROTECTED] wrote:
 Hi Andrew. I'm using a class that was designed to search zip code
 radius's. Here is the piece that gets them.
 
 2 Mile Radius Search From 90606
 $radius=2;
 
 $zipArray1 = $zipLoc-inradius(90606,$radius1);
 $zip_results1=count($zipArray1);
 
 print_r($zipArray1);

Have you tried a print_r directly on the $zipLoc-inradius call?  Is
it a PHP library, and if so, can you look at what inradius is doing to
build that array?

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



Re: [PHP-DB] Re: Convert plain text to HTML tagged text

2004-10-04 Thread Andrew Kreps
On Fri, 1 Oct 2004 23:33:46 -0400, GH [EMAIL PROTECTED] wrote:
 I have a question along this line... is it possible to have PHP do
 more than one str_replace at the same time?

Have a look at the man page, it shows you how to use arrays to
accomplish what you're trying to do.

http://us2.php.net/str_replace

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



Re: [PHP-DB] Setting a timed-session

2004-10-01 Thread Andrew Kreps
On Fri, 01 Oct 2004 14:16:44 -0500, Philip Thompson [EMAIL PROTECTED] wrote:
 This may be a bit elementary, however, I am confused on the
 functionality of it. I am wanting to create a session that logs out
 after a certain amount of time, no matter if the user is doing
 something or not. I have used the function `set_time_limit()`, but I
 don't know if I'm using it properly.

I don't know of any functions built into PHP that have the
functionality you're looking for, but you should be able to simply
store an expiry date/time in your user's session, and if the current
time is past that, destroy the session and send them to a 'time
expired' screen.

Have a look at the session specific portion of the manual for some
helper functions. Also, if you're looking for further guidance, you
might want to re-post this question to the PHP-General list, since
your question isn't DB specific.

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



Re: [PHP-DB] mysql to postgres migration blues...

2004-09-23 Thread Andrew Kreps
On Thu, 23 Sep 2004 20:51:52 +0200, Antoine [EMAIL PROTECTED] wrote:
 declaring it as global didn't seem to work -
 
 global $link;
 /* Connect to database */
 $link = pg_connect(dbname=movies host=localhost user=anton
 password=password)

The global keyword works a little bit differently in PHP.  You need to
inform your function that your variable is global, as opposed to
declaring it as global outside the function.  Like:

$link = database connection

function processData () {
global $link;
...
}

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