Re: [PHP-DB] How to make it case sensitive?

2001-09-21 Thread Jason Stechschulte

On Fri, Sep 21, 2001 at 05:02:14PM +0100, Denny Suvanto wrote:
 The script is just fine until I notice that the
 username is case insensitive. So, if a member has a
 username andy he can log in using 
 andy, Andy, aNdY, andY, and so on. I also
 notice that I can't enter a new member with username
 Andy, anDY, and so on as they will duplicate the
 existing andy. Is this the natural behaviour of
 MySQL or is there anyway to make it case sensitive?
 I'm using PHP 4.0.6  MySQL 3.23.39.

You have to make the column case sensitive, binary will accomplish this.
Something like:

username varchar(20) binary
-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
I think it's a new feature.  Don't tell anyone it was an accident.  :-)
 -- Larry Wall on s/foo/bar/eieio in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Renaming a database name...

2001-09-19 Thread Jason Stechschulte

On Thu, Sep 20, 2001 at 05:04:37AM +0700, Arief Fajar Nursyamsu wrote:
 Can I rename a database name ?

I don't know what database you are using, but you should be able to do
something like this with most of them.

Do a backup of the database.
Create a new database with the new name.
Restore the old database to the new database.

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
Beauty?  What's that?
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Modify Query, or sift through results?

2001-06-28 Thread Jason Stechschulte

On Wed, Jun 27, 2001 at 08:54:04AM -0500, Joseph Koenig wrote:
 I've got a script that searches a db every night and sends out e-mail if
 it finds something a person would be interested in, based on criteria
 they gave us. The problem is that I have one field that stores regions
 of the country in a very unpleasant way. It stores them as:
 
 Northeast;West;South
 
 So all of the regions for one record go into one field. The problem is
 that when searching that, if someone has a preference  of 'North', I
 dont want to pull records that have 'Northeast', as would happen with
 the above example. Is there a way to modify the MySQL query so as to
 find only 'North', keeping in mind that 'North' may be the 3rd in a list
 of semi-colon separated regions? Or do I need to sift through the
 results in PHP to clean them up? Thanks,

You can certainly have MySQL do the work.  I can't modify your query,
because you didn't give it to us, but I can give you an example.

?php
$sql = select * from your_table where your_column rlike North(;|$);
?

This will do a regular expression match.  If either North with a semicolon
directly after it or North and the end of the string is found, the
row will be returned.

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
If you're going to define a shortcut, then make it the base [sic] darn
shortcut you can.
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] MySQL Error???

2001-06-28 Thread Jason Stechschulte

On Wed, Jun 27, 2001 at 10:24:13AM -0600, Brian Grayless wrote:
 Is anyone familiar with this MySQL error?
 1062: Duplicate entry '127' for key 1

The error means you are attempting to put a second record in with the
value of 127.

 I wrote a great bookmark management program that works fine, but everytime I
 insert bookmarks, I insert somewhere over 120 and I start getting this
 error, and it won't add them anymore.  Any suggestions???

I have one idea.  The column is probably a signed tinyint.  tinyints have
a range of -128 to 127.  When you try to put in anything over 127, the
value is out of range, and so apparently tries to reinsert it as 127.

You could change the column to an unsigned tinyint, which would give you
a range of 0 to 255.  Or an unsigned smallint, which gives you a range
of 0 to 65,535.  Just make sure the column is unsigned, since I doubt
you will be storing negative numbers in the column.  This can be done
easily from the mysql client:

alter table your_table modify your_column smallint unsigned;
-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
/* This bit of chicanery makes a unary function followed by
a parenthesis into a function with one argument, highest precedence. */
 -- Larry Wall in toke.c from the perl source code

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Extracting enum/set values from database

2001-06-27 Thread Jason Stechschulte

On Fri, Jun 22, 2001 at 04:45:53PM -0700, Todd A. Jacobs wrote:
 Is there a way to dynamically build an option list from an enum/set type?
 In other words, if I don't know the possible values of the enum or set
 field ahead of time, how can I retrieve that information at run-time?

Here is a function I use to dynamically build an option list.  You send
it the table and column.  Database and columnType are optional.  The
function returns the values of the column as an array.

?php
function getEnumValues($table, $column, $database=default,
$columnType=enum) {
   $mylink = connect();
   $sql = describe $table;
   $thisResult = mysql_db_query($database, $sql, $mylink);
   while($table = mysql_fetch_array($thisResult)) {
  if($table[Field] == $column  $columnType == enum) {
 return explode(,, preg_replace(/^enum\(|'|\)/i, ,
  $table[Type]));
  }
  elseif($table[Field] == $column  $columnType == set) {
 return explode(,, preg_replace(/^set\(|'|\)/i, ,
  $table[Type]));
  }
   }
}
?

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
It is my job in life to travel all roads, so that some may take the road
less travelled, and others the road more travelled, and all have a
pleasant day.
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Variable Variables in PHP

2001-06-27 Thread Jason Stechschulte

On Wed, Jun 27, 2001 at 12:03:42PM +1000, Morgan Tocker wrote:
 ## THIS SHOULD SUBMIT SOMETHING LIKE THIS 
 
 test.php?name1=avalueemail1=avalueagainname2=secondnameemail2=secondemail
 
 THE PROBLEM:
 From PHP with variable variables, how do I change $name1 and $email1 into -
 
 ## for all $name.$x values do this..
 $sql = UPDATE name_and_email SET name = '$name1', email = '$email1' WHERE
 id = '$id';

Put it inside of a loop.

for($i = 1; $i  3; $i++) {
   echo ${name$i};
}

This will print out both names.  Hopefully you can figure out how to
modify this to create the sql code you want.

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
It's the Magic that counts.
 -- Larry Wall on Perl's apparent ugliness

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Sql result loop problem !

2001-05-18 Thread Jason Stechschulte

On Fri, May 18, 2001 at 04:32:51PM +0200, Keith Whyman wrote:
 while ($p = mysql_fetch_array($result1)) {
 
 $msg .= $p[s_bereich_name];
 $msg .= $p[s_news_text];
 $msg .= $p[s_users_real_name];

I'm not sure if this is what you want, but something like this maybe??

?php
while($p = mysql_fetch_array($result)) {
   if($p[s_bereich_name] != $oldBereichName) {
  echo $p[s_bereich_name].br\n;
  $oldBereichName = $p[s_bereich_name];
   }
   echo $p[s_news_text]. - .$p[s_users_real_name].br\n;
}
?

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
If I allowed next $label then I'd also have to allow goto $label,
and I don't think you really want that...  :-)
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] php - MSSQL

2001-05-14 Thread Jason Stechschulte

On Mon, May 14, 2001 at 12:11:17PM +0200, Dragan Dinic wrote:
 Hi there.

Hi.

 Is there any possible way to connect PHP (running on apache 1.3.12 on Red
 Hat Linux 7) with Microsoft SQL server (running on Windows 2000) ?

Yes

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
Perl itself is usually pretty good about telling you what you shouldn't
do. :-)
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Backup Database

2001-05-11 Thread Jason Stechschulte

On Fri, May 11, 2001 at 10:02:41AM +0800, Jennifer Arcino Demeterio wrote:
 what will i do to have a realtime backup of my database?

It would help to know which database you are using.

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
Your csh still thinks true is false.  Write to your vendor today and tell
them that next year Configure ought to rm /bin/csh unless they fix their
blasted shell. :-)   -- Larry Wall in Configure from the perl distribution

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] mp3 upload????

2001-05-04 Thread Jason Stechschulte

On Thu, May 03, 2001 at 06:44:38PM -0400, Kelvin wrote:
 Hi,
I want to setup a upload program thats only allow MP3 file type.
 So,  this is my coding under the file
 
 .
 if ($imgfile_type == audio/mp3)
 ..
 ...
 But when I upload my song, it said mp3 is not the format type   What
 should I do?
 Please help. I will be very appreciate.

Print out $imgfile_type to see what it is.
-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
No, I'm not going to explain it.  If you can't figure it out, you didn't
want to know anyway...  :-)
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] newbie: showing records from SQL

2001-05-01 Thread Jason Stechschulte

On Sat, Apr 28, 2001 at 07:06:31PM +0200, twopeak wrote:
 I managed to find out how to add records in my table, but I can't find out
 how to show records...
 Are there manuals on the web that are specific to php  sql?
 I've found manuals for both, but they both give only a little bit of
 information, and refer to the other website for more information...

Have you even tried looking yourself??  The page below has many links to
examples, tutorials, and many other useful things.

http://www.php.net/links.php
-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
The way these things go, there are probably 6 or 8 kludgey ways to do
it, and a better way that involves rethinking something that hasn't
been rethunk yet.
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] MySQL Question

2001-04-18 Thread Jason Stechschulte

On Tue, Apr 17, 2001 at 05:52:53PM -0400, Peter J. Krawetzky wrote:
 How do you move the database files to another location in MySQL?  I am
 running Redhat 7.1 with MySQL version 3.23.33.

You ask the appropriate list @ [EMAIL PROTECTED]  

Of course by the time you do so, you have already searched the archives
@ http://www.mysql.com/documentation/searchlists.html

As well as simply looking on the site @ http://www.mysql.com

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
Randal said it would be tough to do in sed.  He didn't say he didn't
understand sed.  Randal understands sed quite well.  Which is why he
uses Perl.   :-)  -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] How to back up database..... ?

2001-04-16 Thread Jason Stechschulte

On Mon, Apr 16, 2001 at 12:40:05AM +0800, E K L wrote:
 Hi all,
Is there anyone can tell me how to back up Mysql database from one server 
 to other server? Please advisethanks

backup to zip:
mysqldump --add-drop-table -u root -ppass database | gzip  /dir/database.gz

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
Remember though that
THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR.
 -- Larry Wall in the perl man page

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] ALTER TABLE - code not working.

2001-03-29 Thread Jason Stechschulte

On Thu, Mar 29, 2001 at 12:20:41PM +0100, Martin E. Koss wrote:
 I have been trying to get a new column added to a table (vips) via a PHP
 script, but having exhausted all the things I can find, I'm still
 struggling. I've referred t TFM for all those who just can't wait to tell me
 to do so, and believe my SQL statement is correct:
 
 $NewCol = $Prod_Code;
 $defaultvalue = "0.00";
 // make usual connection
 $conID = mysql_pconnect ("localhost","admin","mek1233");
 mysql_select_db("FocusDynamics", $conID);
 // set the query
 $AddColQuery = "ALTER TABLE vips ADD COLUMN $NewCol";
 $result = mysql_query ($AddColQuery,$conID);
 // now set the default value for all rows in vips table
 $SetDefault = "UPDATE TABLE vips SET $NewCol=$defaultvalue";
 $result = mysql_query ($SetDefault,$conID);
 
 It is NOT adding the column, and obviously not setting the default.

If you haven't gotten a fix for this yet, then try adding:

echo "$AddColQuerybr\n".mysql_error($conID)."br\n";

after your mysql_query() call.  This allows you to see the exact sql you
are executing, and you will get to see the error mysql is returning.
This has helped me find something strange with what I was doing when I
could have sworn there was nothing wrong with my code.

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
As someone pointed out, you could have an attribute that says "optimize
the heck out of this routine", and your definition of heck would be a
parameter to the optimizer.
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] ALTER TABLE - code not working.

2001-03-29 Thread Jason Stechschulte

On Thu, Mar 29, 2001 at 05:31:39PM +0100, Martin E. Koss wrote:
 I just pasted:
 ALTER TABLE vips ADD NewAD FLOAT (11,2) DEFAULT '0.00' NULL
 into the 'Run SQL' box on phpMyAdmin and it did exactly what it should do. I
 did it both online (hosting servers) and offline on my Win/Apache and both
 are fine, new column added.
 
 However, via the PHP script we're discussing it doesn't create the column or
 generate an error. The username and password that phpMyAdmin uses is the
 same as the one the connections for the web site uses and that includes full
 privelidges.

There is still one thing I want to be clear on.  Are your php script and
phpMyAdmin running on the same server?  With mysql you can give
privileges to a user on a specific server, so user foo on server bar
could have different privileges than user foo on server bar2.  This is
the only thing that I can think of that might be happening.  

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
But you have to allow a little for the desire to evangelize when you
think you have good news.
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] SQL Select?

2001-03-27 Thread Jason Stechschulte

On Sat, Mar 24, 2001 at 08:55:13PM -, Grant wrote:
 Is there any way of using a string in an SQL query instead of using the
 table name. Something along the lines of
 
 $result=mysql_query("SELECT * FROM $tablename",$db);
 
 this doesnt work it come up with a parse error

Your problem is probably on a line above this one.  Because this line
should be valid.  I do stuff like  this all the time and it works
without any problems so far.

?php
// First of all, I use a variable to hold my sql statement:
$sql = "select * from $tablename";
// Then perform the query:
$result = mysql_query($sql, $db) or die("$sqlbr".mysql_error($db));
?

This allows you to see the sql that is actually being executed, and you
also get to see the actual mysql error.
-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
It is, of course, written in Perl.  Translation to C is left as an
exercise for the reader.  :-)  -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] mysql grant problem?

2001-03-26 Thread Jason Stechschulte

On Sat, Mar 24, 2001 at 11:22:37PM +0800, Fai wrote:
 When we use grant as following:
 GRANT select(col_name_1) on db_name_1.tbl_name_1 to peter identified by
 "peter";
 
 Then peter can only select the field of col_name_1 on the tbl_name_1 of
 db_name_1.
 
 However, when peter issue the query: DESC tbl_name_1; he can see all the
 structure of that table. This makes that peter does not know which column he
 can use.
 
 Does any body know how to make peter only can see the column which he has
 right to use it when he issue DESC tbl_name_1.

I'm not sure but I think this is a question that should have been posted
to a Mysql list.  

[EMAIL PROTECTED]

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
OOPS!  You naughty creature!  You didn't run Configure with sh!
I will attempt to remedy the situation by running sh for you...
 -- Larry Wall in Configure from the perl distribution

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] How do I test on number of fields ?

2001-03-20 Thread Jason Stechschulte

On Mon, Mar 19, 2001 at 10:06:52PM -0800, Toke Herkild wrote:
 I've written this login rutine
 
 But that doesn't work... I've tried to use mysql_num_rows too but I still
 get :
 bWarning/b:  Supplied argument is not a valid MySQL result resource in
 bg://web/herkild/html/loginout.php/b on line b113/bbr
 
 if ($ACTION == 'Login') {
   $query = "SELECT user.ID FROM user WHERE ";
   $query .= "user.brugerID = $LoginBrugerID AND ";
   $query .= "user.kodeord = $LoginKodeord;";
 
   $mysql_result = mysql_query($query, $mysql_link);
 
 (line 113 )  if ($row = mysql_fetch_row($mysql_result)){
 setcookie("Herkild_Domain", $row[0]);
 Logged_in();
   }
   else {
 wronguser();
   }
 }

It looks like you might be missing some quotes in your query.  After you
call mysql_query(), call mysql_error($mysql_link);  It will show you
your error in your query.

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
There are still some other things to do, so don't think if I didn't fix
your favorite bug that your bug report is in the bit bucket.  (It may be,
but don't think it.  :-)  Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] What is the life time of mysql connection if I use pconnect()

2001-03-15 Thread Jason Stechschulte

On Thu, Mar 15, 2001 at 11:55:20AM +0800, Carfield Yim wrote:
 From the document, the connection opened by pconnect() will not close
 after you use. 
 And it will store it and reuse at next time. 
 I would like to ask, it is keep open until I shutdown apache?

AFAIK, it is kept open for the life of that apache process.

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
'Course, I haven't weighed in yet.  :-)
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] php/mysql

2001-02-22 Thread Jason Stechschulte

On Wed, Feb 21, 2001 at 10:58:27PM +0100, Ramiro Radjiman wrote:
 the following code repeats saying ERORR : cannot execute query.
 if i delete the text IF NOT EXISTS al goes good.
 I don't understand why.

Check the version of mysql you are using.  From the manual:
In MySQL Version 3.23 or later, you can use the keywords IF NOT EXISTS
so that an error does not occur if the table already exists. 

http://www.mysql.com/doc/C/R/CREATE_TABLE.html

-- 
Jason Stechschulte
[EMAIL PROTECTED]
--
The way these things go, there are probably 6 or 8 kludgey ways to do
it, and a better way that involves rethinking something that hasn't
been rethunk yet.
 -- Larry Wall in [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]