Re: [PHP-DB] Re: php/mysql weblog - addnews function problems

2004-02-18 Thread Doug Thompson
On Wed, 18 Feb 2004 09:35:22 -, Slippyaah wrote:

>Well basically I think it's a problem with the declaration of variables
>and/or the way they are being processed by the form.
>
>Here is the individual addNews function:
>
>function addNews() {
>   global $db;
>
>   /* declare variables here? */
>
>
>
>   /* insert the new news entry */
>   $query = "INSERT INTO news" .
>  "VALUES('',$id,'{$_POST['postdate']}'," .
>  "'{$_POST['title']}',".
>  "'{$_POST['newstext']}')";

I haven't been following this thread, but you need to do your part to help the parser.

$query = "INSERT INTO news ";
$query .= "VALUES('',$id,'".$_POST['postdate']."',";
$query .= "'".$_POST['title']."',";
$query .= "'".$_POST['newstext']."')";

You should also add some db error checking and reporting, then you wouldn't get the 
erroneous "success" message.

hth,
Doug

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



Re: [PHP-DB] Q

2004-02-22 Thread Doug Thompson

On Sun, 22 Feb 2004 11:02:29 EST, [EMAIL PROTECTED] wrote:

>Dear friends,
>
>I have pap4, mysql, apache installed. How do I enable to access
> /"$_SERVER[PHP_SELF]/"
>.Comments, please

Correct your syntax errors:

\"$_SERVER['PHP_SELF']\"


Doug

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



Re: [PHP-DB] SQL File Import problem (Was: HELP!!!)

2004-02-26 Thread Doug Thompson
On Fri, 27 Feb 2004 01:16:20 +0100, Erwin Kerk wrote:

>Robin 'Sparky' Kopetzky wrote:
>
>> Good afternoon!
>> 
>> I used SQLYOG to export the tables and data from a Mysql database. Now, when
>> i try to re-import the data back into a different database, I get an error
>> stating "Error : MySQL server has gone away". What is happening and how do I
>> fix this. I NEED this script to execute badly. I even tries running it under
>> mysql using source "filename.sql" and got the same error. One table is over
>> 75,000 entries.
>The queries are taking too long. Are this plain .sql files? If so, try 
>to split them up in say, 10 separate files, and import them all 
>separately. That should work.
>
>And in the futue, try putting a more descriptive text in youre subject.
>
>
>Erwin Kerk
>Web Developer
>
>-- 

Erwin is exactly right.That being said:

You don't say and it's risky to assume if you can do any other tasks on the new 
server.  In other words, is it running at all?

You don't say which of SQLyog's methods you used to create the backup.  In this case, 
I would have used 
DB -> Export Database as Batch Scripts 
and I would save the file as .sql and transfer that file to the mysql/bin 
directory on the new system.

Assuming mysqld is running on the new system, cd to the mysql/bin subdirectory and type
./mysql -uusername -ppassword < somefile.sql

Of course, all the foregoing syntax for re-installing presumes *n*x.

I move databases from my local windows system to a remote *n*x site frequently using 
the above process and it is very reliable and repeatable.

hth,
Doug

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



Re: [PHP-DB] MySql PHP API

2004-03-01 Thread Doug Thompson
On Mon, 1 Mar 2004 17:16:01 -0800 (PST), Mike Ni wrote:

>Hey everyone,
>
>
>Does anyone outhere is running Apache/Linux/PHP/Mysql?
>
>I am having hard time with "MYSQL PHP API". Apache/PHP
>simply would not recognize any cmysql function call
>such as "mysql_connect".
>
>I have recompile the php with mysql extension and th
>problem continue tobe there. 
>
>I run the "phpifo" and it work.
>In smuuary:
>
>* Beside Mysql, PHP seems to be working including
>phpino
>* According to phpinfo( ), it suuport mysql. Yet,
>wouldn't recognize the functin call
>
>
>Plese let me know if you have any thought.
>
>Thanks!

Mike:

You don't say if you are trying to get a new installation running for the first time 
or are these scripts that were working at one time and something has changed that has 
caused them to stop working?  Is the installation on your local machine or on a remote 
server?

More importantly, you need to provide a cut-and-paste copy of the portion of the code 
that isn't working and all error messages being returned by the system.

Finally, please don't cross port to several lists at once.

Regards,
Doug

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



Re: [PHP-DB] Password encryption

2004-03-04 Thread Doug Thompson
On Thu, 04 Mar 2004 12:46:51 -0600, Mignon Hunter wrote:

>Can anyone recommend, or does anyone have handy, a script that will encrypt passwords 
>AND then also be able to retrieve the encrypted password.  
>
>Checking out the docs and some books has confused me mostly.
>
>Thx
>

Yes and no.

$pw = md5("password");   works well.

However, you cannot decrypt.

You store $pw (above) in the database and when a user wants to log in, you encrypt 
their entry and compare it to the value -- also encrypted -- stored in the db.  If 
there is a match, they get in; but you have no knowledge of their password(s).  
Neither does anyone else who hacks in.

hth,
Doug

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



Re: [PHP-DB] Password encryption

2004-03-04 Thread Doug Thompson
It is a string function that returns a 32-character md5 hash of "password."  MD5 is 
the name for a current RSA Message Digest Algorithm encryption method.

A search in the manual for md5 gets you to the little bit of information in the manual 
plus a link to RFC 1321 which likely provides more information than you want.

Doug

On Thu, 4 Mar 2004 15:35:52 -0500, Kevin wrote:

>Hi Doug and All,
>
>I am real new to PHP and wanted to know if you can explain the
>[md5("password");]  code? Is this a set function?
>
>Thanks,
>Kevin
>
>- Original Message - 
>
>> On Thu, 04 Mar 2004 12:46:51 -0600, Mignon Hunter wrote:
>>
>> >Can anyone recommend, or does anyone have handy, a script that will
>encrypt passwords AND then also be able to retrieve the encrypted password.
>> >
>> >Checking out the docs and some books has confused me mostly.
>> >
>> >Thx
>> >
>>
>> Yes and no.
>>
>> $pw = md5("password");   works well.
>>
>> However, you cannot decrypt.
>>
>> You store $pw (above) in the database and when a user wants to log in, you
>encrypt their entry and compare it to the value -- also encrypted -- stored
>in the db.  If there is a match, they get in; but you have no knowledge of
>their password(s).  Neither does anyone else who hacks in.
>>
>> hth,
>> Doug
>>
>

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



Re: [PHP-DB] How to calculate size of INT(x) field

2004-03-05 Thread Doug Thompson
Richard,

Why do you exclude the MySQL Manual from your list of references?

See sections 6.2 and 6.2.1.  In 6.2.1, you will find:

Another extension is supported by MySQL for optionally specifying 
the display width of an integer value in parentheses following the 
base keyword for the type (for example, INT(4)).


There is much more about how INT(x) works, but if I copied it all to
here you wouldn't discover the other useful information available.

Doug


On Fri, 5 Mar 2004 11:29:03 +, Richard Davey wrote:

>Hi all,
>
>Sorry for such a newbie question! But I have been digging through the
>O'Reilly MySQL book + MySQL Cookbook and cannot find an answer to what
>I think is a very simple question:
>
>When creating an unsigned INT field, how does the value in brackets
>(if given) limit the size of the field? I.e. what is the difference in
>possible maximum values held between an INT(10) and an INT(4)? I know
>MySQL will create an INT(10) as standard but I'm not sure I need it to
>be able to hold a number that high.
>
>-- 
>Best regards,
> Richard Davey
> http://www.phpcommunity.org/wiki/296.html

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



Re: [PHP-DB] Re: How to calculate size of INT(x) field

2004-03-05 Thread Doug Thompson
On Fri, 5 Mar 2004 16:45:12 -0500, Chris Ruprecht wrote:

>On Friday 05 March 2004 06:36, Kae Verens wrote:
>> Richard Davey wrote:
>> > Hi all,
>> >
>> > Sorry for such a newbie question! But I have been digging through the
>> > O'Reilly MySQL book + MySQL Cookbook and cannot find an answer to what
>> > I think is a very simple question:
>> >
>> > When creating an unsigned INT field, how does the value in brackets
>> > (if given) limit the size of the field? I.e. what is the difference in
>> > possible maximum values held between an INT(10) and an INT(4)? I know
>> > MySQL will create an INT(10) as standard but I'm not sure I need it to
>> > be able to hold a number that high.
>>
>> IIRC, the highest permitted value of an unsigned int is:
>> 8^(number of bytes)-1
>>
>> so, INT(4) above is 8^4-1 (approx 65500), and INT(10) is 8^10-1 (quite a
>> bit bigger)
>
>The X in Int(X) is the number of byes, each byte has 8 bits, hence, a 4 byte 
>integer has 32 bits, a 8 byte integer has 64 bits.
>
>actually, Int(4) is 2^(4 x 8 bit) - 1 = 4294967295
>Int(8) = 2^(64) - 1 = 18446744073709551615
>
>Usually, a distinction is made between signed and unsigned, most database 
>systems use signed integer, so the maximum int(4) value is 2^32 / 2 - 1 or 
>2^31 - 1 and the max signed int(8) value = 2^63 - 1.
>

The value in parentheses in INT(x) is unrelated to the possible values in the column 
which, in the MySQL integer number column type declarations, are defined by INT, 
SMALLINT, MEDIUMINT, and BIGINT.

Reading the mysql manual instead of engaging in unrestrained speculation, you would 
learn that:

"As an extension to the SQL-92 standard, MySQL also supports the integer types 
TINYINT, MEDIUMINT, and BIGINT as listed in the tables above. Another extension is 
supported by MySQL for optionally specifying the display width of an integer value in 
parentheses following the base keyword for the type (for example, INT(4)). This 
optional width specification is used to left-pad the display of values whose width is 
less than the width specified for the column, but does not constrain the range of 
values that can be stored in the column, nor the number of digits that will be 
displayed for values whose width exceeds that specified for the column. ..."

http://www.mysql.com/documentation/mysql/bychapter/manual_Column_types.html#Numeric_types

Pay particular attention to the second and third sentences in the excerpt above.

Doug



>Best regards,
>Chris
>
>>
>> Kae
>

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



Re: [PHP-DB] Pulldown value not passed to next page

2004-03-11 Thread Doug Thompson
Hi Karen,

Depending upon the method used for your form, you should be able to find the value in either $_GET['pagesize'] or $_POST['pagesize'].

hth,
Doug


Karen Resplendo wrote:
What is wrong with this picture? I build a pulldown for selecting page size(number of rows in one page). If page is new, it gives the default (selected) of 15. For some reason, when Previous/Next are clicked, the value passed is still 15 even though the pulldown says something else (5 or 15 or whatever). Down below my pulldown code is the code to call the Next/Previous pages (just the important part)>
 
**
Pulldown built here
**
   //use rcan select page size from a pulldown
 $myArray = array('5','10','15','20','25','30','35', '40');
$numElements = count($myArray);
 If(!$pagesize)
  {
   $pagesize=15;
  }
echo "";
/*loop through filling  pulldown*/
  for($i=0;$i<=$numElements;$i++){ 
  echo "".$myArray[$i]."\n";
}
Else
{
 echo ">".$myArray[$i]."\n";
}
  }  
echo "";
 

link when Next/Previous clicked
***
 
else// not the last page, link to the next page 
echo "Next"; 

-
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] tick mark `

2004-03-22 Thread Doug Thompson
Craig:
I don't see a reply to your question in today's posts.
"Backticks" or "tick marks" allow you to use reserved words for column names.  Interval is a reserved word.

Hope you weren't waiting this long for a response.

Doug Thompson

Craig Hoffman wrote:
Why is it when I have this ` tick mark in my query it works fine, but 
when I remove them it I get an error?

Error: You have an error in your SQL syntax. Check the manual that 
corresponds to your MySQL server version for the right syntax to use 
near 'interval, heartrate, morning_hr, hr_for_intervals, watts, rpms,

Here is my query:
$query = "INSERT INTO traininglog ( `user_id` , `power_level` , `weight` 
, `comments` , `workout` , `distance` , `time` , `interval` , 
`heartrate` , `morning_hr` , `hr_for_intervals` , `watts` , `rpms` , 
`date` , `time_upload` , `week_of` , `sleep` , `motivation` , 
`workout_name` , `rpe` , `candence` , `crunchs` , `leg_raises` , 
`situp_with_twist` , `superman` , `situps` , `russian_twist` , 
`back_extensions` , `situp_crunchs` , `side_crunchs` , 
`balance_bicycles` , `v_ups` , `leg_rotation` , `medicine_ball_throw` , 
`pull_ups` , `push_ups` , `climbing` ) VALUES ($_POST[user_id], 
'$_POST[power_level]', $_POST[weight], '$_POST[comments]', 
'$_POST[workout]', '$_POST[distance]', '$_POST[time]' '.'
'$_POST[interval]', $_POST[heartrate], $_POST[morning_hr], 
$_POST[hr_for_intervals], $_POST[watts], $_POST[rpms], $_POST[date], 
NOW('$_POST[time_upload]') '.'
'$_POST[week_of]', $_POST[sleep], '$_POST[motivation]', 
'$_POST[workout_name]', $_POST[rpe], $_POST[candence], $_POST[crunchs], 
$_POST[leg_raises], $_POST[situp_with_twist] '.'
$_POST[superman], $_POST[situps], $_POST[russian_twist], 
$_POST[back_extensions], $_POST[situp_crunchs], $_POST[side_crunchs], 
$_POST[balance_bicycles], $_POST[v_ups] '.'
 '$_POST[leg_rotation]', $_POST[medicine_ball_throw], $_POST[pull_ups], 
$_POST[push_ups], '$_POST[climbing]' )";__
Craig Hoffman - eClimb Media

v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Strange problem with mySQL

2004-03-25 Thread Doug Thompson
Brown, Craig wrote:


I am trying to update a database that I use to store user names and the 
hashed values of passwords. The database name is Login, the table is 
"users".

I have the following commands in my php file.

@ $db=mysql_pconnect('localhost','apache','password');
mysql_select_db('Login');
$query="UPDATE users set pw='$hash' WHERE id='$user'";
$results = mysql_query($query);
The result is always false. If I enter the value of $query into a 
console (such as mysqlcc). The command works fine. Any ideas?

Thanks!

Craig

Actually, you are entering at the console the value you are hoping $query will have.  You never test to see what $query actually is or what is the error.  Do you know for sure that the correct value of $user is being parsed?  Do you even know that the script made a valid  connection and db selection?

Put an ECHO $query; statement and some other error checking in there and quit tearing out your hair over assumptions that may be wrong.

Doug

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


Re: spam: [PHP-DB] php, mysql security question

2004-03-31 Thread Doug Thompson
JeRRy wrote:






Hi,

I have a php, mysql security question.

You know how there is a way to enable/disable hot
linking to your images via CPanel to allow/disallow
people to link to your images from an external site? 
Well is there a way to allow/disable external sites
connecting to a mysql via PHP?

So is there a way to allow only localhost access to
the db's somehow?
I wonder this to add extra security to my db's and not
only that to educate others on this list if it is
possible or not.
Thanks for your time.

J
Even if your db server doesn't sit behind a firewall, you can always restrict what userid/password/address combinations can gain access to what DB / Tables / Columns and what functions they can perform (select, insert, update, etc.) in those areas using the MySQL administration features.  I have different PHPUsers for my scripts that have varying levels of authorization to coincide with what the scripts need to do -- Select (read only), Update (can only revise existing records), Insert (can add new new records), etc.  All the db_connect scripts are well_outside the public areas to minimize opportunities to compromise the userid/pw.

Start here:  http://www.mysql.com/doc/en/Security.html

All of which forces the conclusion that this isn't a PHP issue at all.

DT

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


[Fwd: Re: [PHP-DB] php, mysql security question]

2004-03-31 Thread Doug Thompson
Oops.  For some reason my filter concluded your email was spam and it modifies the 
subject line.  I missed  cleaning the subject line on the first reply.  Here is is 
again in case others filter on that keyword.  I apologize for the double post and 
possible confusion.
\Doug
JeRRy wrote:
 
Hi,

I have a php, mysql security question.

You know how there is a way to enable/disable hot
linking to your images via CPanel to allow/disallow
people to link to your images from an external site? 
Well is there a way to allow/disable external sites
connecting to a mysql via PHP?

So is there a way to allow only localhost access to
the db's somehow?
I wonder this to add extra security to my db's and not
only that to educate others on this list if it is
possible or not.
Thanks for your time.

J
Even if your db server doesn't sit behind a firewall, you can always restrict what userid/password/address combinations can gain access to what DB / Tables / Columns and what functions they can perform (select, insert, update, etc.) in those areas using the MySQL administration features.  I have different PHPUsers for my scripts that have varying levels of authorization to coincide with what the scripts need to do -- Select (read only), Update (can only revise existing records), Insert (can add new new records), etc.  All the db_connect scripts are well_outside the public areas to minimize opportunities to compromise the userid/pw.

Start here:  http://www.mysql.com/doc/en/Security.html

All of which forces the conclusion that this isn't a PHP issue at all.

DT

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


Re: [PHP-DB] Can't access HTTP Post Array

2004-04-10 Thread Doug Thompson
[EMAIL PROTECTED] wrote:

I'm running Apache/2.0.49 and PHP/4.3.5 on windows XP with MSIE 6.0. -- local host.

When I try to access the variables in the array (HTTP POST), they are empty or null. Did I miss a PHP or Apache setting in the php.ini or httpd.conf?

Use$_POST['array_element']

Doug

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


Re: [PHP-DB] Handling missing rows on joins

2004-04-21 Thread Doug Thompson
-{ Rene Brehmer }- wrote:
Working with PHP 4.3.0 and MySQL 4.0.14 (but code MUST be compatible with
3.23.56).
For my forums, I've got this 4-way join to load (and output) the posts with
info on the poster:
$fullthread = "SELECT
postID,hf_posts.userID,name,time,post,edit,nickname,joined,location,posts,levelname
   FROM hf_posts,hf_users,hf_user_stats,hf_levels
   WHERE hf_posts.threadID='$threadID' AND
hf_posts.userID=hf_users.userID AND hf_user_stats.userID=hf_users.userID AND
hf_levels.levelID=hf_users.levelID
   ORDER BY hf_posts.time ASC";
clipped--
hf_posts has postID as primary key, and threadID and userID as foreign keys.
hf_users has userID as primary key, and levelID as foreign key.
hf_user_stats is basically an extension of hf_users, and thus only have
userID as primary key, but it also functions as foreign key.
hf_levels has levelID as primary key, and no foreign keys (it's a top-level
table in the relations).
--clipped
But here comes the problem: If a user is deleted, the records from hf_users
and hf_user_stats will be gone. On the join, this means that any posts made
by the deleted users will not be included, and thus not displayed -- they
become dangling posts in the database ...
I haven't actually written the code to delete users yet, but my current idea
for a workaround is that on deleting the users, changing all their posts to
userID 1 (the system guest level). This would atleast let the posts be
displayed, although make those posts display as posted by a guest, and
because the displayname is stored with the post, it would not list as
Visitor/guest.
What I have problem with is figuring out whether this is a kludge or the
only way to do it. Or is there a better way to make the join so it will
include the posts even if it cannot find anything to join with in hf_users
and hf_user_stats ???
I know it looks like deleting levels will cause problems as well, but the
code for that has been made so deleting a level will move all users assigned
to that level to a different one.
Any suggestions for handling this better would be appreciated ... 

TIA 

Rene
Maybe I haven't had enough coffee, yet, but my first inclination is to suggest adding a user_status flag to hf_users.

Doug

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


Re: [PHP-DB] supernoob strikes again

2004-05-09 Thread Doug Thompson
Dan Bowkley wrote:
got it...rather than return false, mysql_result throws an error if the query
returns nothing.  What a pain.
NOT True.

If the query is syntactically valid and nothing matches, mysql returns zero rows which is not an error, at least on the part of the dbms.  Use mysql_num_rows() to test for this condition.

Doug

Finished product at
http://www.dibcomputers.com/new-dibcomputers/index.php.txt if anyone wants
to steal it...
D
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] PostgreSQL lib and character case

2004-04-28 Thread Doug Thompson
Tumurbaatar S. wrote:
I use pg_fetch_array() to get a record content. But it seems that
to access elements of  the returned associative array, I should
use lowercase field names. Is there any way to use case-insensitive
field names?
Assuming you want all lower case, convert the form field entry using strtolower().

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


Re: [PHP-DB] Getting a result from MAX() query

2004-07-13 Thread Doug Thompson
[EMAIL PROTECTED] wrote:
Would somebody be kind enough to explain why this query produces a false result
$latest=mysql_query("SELECT MAX(fee_recd) FROM members",$connectup)or die
("Query failed:$latestError: " . mysql_error());
but this one doesn't
$latest=mysql_query("SELECT fee_recd FROM members ORDER BY fee_recd DESC
LIMIT 1",$connectup)or die ("Query failed:$latestError: " .
mysql_error());
Louise
Here's a concept:  RTM
"In MySQL versions prior to Version 3.22.5, you can use MAX() instead of GREATEST. "
What does your inquiry have to do with PHP?
Doug
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Case sensitive search

2004-07-18 Thread Doug Thompson
Rosen wrote:
Hi,
I have a simple table:
test (
  id int unsigned NOT NULL auto_increment,
  data varchar(30) default NULL,
  PRIMARY KEY  (id))
with two simple records:
id  data
1   "a"
2   "A"
When I perform "select * from test where data='a' " - it return me both
rows.
http://dev.mysql.com/doc/mysql/en/Case_Sensitivity_Operators.html
Doug
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Php if statement in a form

2004-08-05 Thread Doug Thompson
if (is_null($row["timeout"]).)
[EMAIL PROTECTED] wrote:
Still no joy. The parse error actually refers to the --  if
($row["timeout"] IS NULL); --- line.
-Original Message-
From: Eric Schwartz [mailto:[EMAIL PROTECTED] 
Sent: Friday, 6 August 2004 11:32 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Php if statement in a form

Sorry.  Forgot to remove the word echo from that line.
On Thu, 5 Aug 2004 21:29:01 -0400, Eric Schwartz
<[EMAIL PROTECTED]> wrote:
On Fri, 6 Aug 2004 10:21:19 +1000, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
Thanks Eric,
I have changed it somewhat but am just getting a parse error,
unexpected T_STRING on that line.
My revised code is below:
print "Current Staff Working Alone";
print "";
print "\n";
print "\n";
print
"NameLocationTime
inTime Out/tr>";
while ($row = mysql_fetch_array($result, MYSQL_BOTH))
{
   print "";
   print "";
   print "";
   print $row["name"];
   print "";
   print $row["location"];
   print "";
   print $row["timein"];
   print "";
   if ($row["timeout"] IS NULL);
   {
   print date('H:i')">;
   } else {
   print $row["timeout"];
   }
   print "\n";
   }
   print "\n";
click
here to record your timeout">

-Original Message-
From: Eric Schwartz [mailto:[EMAIL PROTECTED]
Sent: Friday, 6 August 2004 9:31 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Php if statement in a form
On Fri, 6 Aug 2004 08:53:53 +1000, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
Hello, I wonder if someone could point me in the right direction
here.
I have a table that is displayed that is also a form, and allowed
a
person to select a record to update using a radio button. With one
of
the fields of the form/table however, I would like it to display
the
value in the db (if there is one). If there is no value then I
want
the
field to display the current time and then submit it to the db as
a
variable.
I can get it to display the current time and submit it to the db,
but
I
don't know how to do the IF bit of the form/table.
Anyway, the code is below.
Thanks
FROM
workalone WHERE date=CURRENT_DATE()") or die (mysql_error());
// Display the results of the query in a table
print "Current Staff Working Alone";
//below is the table/form with the id, name, location, timein and
timeout taken from the db
print "cellspacing=\"0\">\n";
print
"NameLocationTime
inTime Out/tr>";
while ($row = mysql_fetch_array($result, MYSQL_BOTH))
{
   print "";
   print "";
   print "";
   print $row["name"];
   print "";
   print $row["location"];
   print "";
   print $row["timein"];
   print "";
//below is the IF thing I am having problems with
   ?>
echo date('H:i');?>} else {">\n";
}
print "\n";
?>click
here to record your timeout">   
if ($submit2)
{
$dbcnx = @mysql_connect( "localhost", "user", "password");
mysql_select_db("movements");
$result = mysql_query("UPDATE workalone SET timeout='$timeout'
WHERE
id='$id'") or die (mysql_error());
echo "Thank you, your Time Out has been recorded.";
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

You seem to have your php tags not around your if statement and you
are checking to see if $timeout rather than $row["timeout"] has a
value.  I also think the proper way to check for NULL is to say IS
NULL or NOT NULL, not $foo = NULL.  Could be wrong about that one.

--
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

Try adding a quote on the line and escaping the other quotes, like
this:
print "date('H:i')."\">";

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


Re: [PHP-DB] MySQL denying access to...everything

2004-08-18 Thread Doug Thompson
[EMAIL PROTECTED] wrote:
I finally got my PHP5 installation to support MySQL and now this. When I try 
to edit anything on mysqlgui.exe, it just gives me this error: error in 
database function: access denied for user @localhost...

I don't know if this has to do with my php installation or what. If not, 
flame me for all I care. I'm too sick of all this mess to care.

...somebody help...
http://dev.mysql.com/doc/mysql/en/User_Account_Management.html
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Q

2004-08-22 Thread Doug Thompson
[EMAIL PROTECTED] wrote:
Dear Friends,
Data in the table is displayed by php query.
.Say column A, in which name of company will be stored.
Now i want to add another column B to table in which web addresse will be 
stored against each name in Column B.and same should be displayed in an html  
table, when seen in browser with link to each web address in table.

The php query I am using now, is posted below.
What additional code should I add so that data in column A in table1 is 
displayed in tabular form, with a link "on click", to web address in column B.

Guidance to further Query, please.

Present Query


// pick the database to use
mysql_select_db("b",$conn);
// create the SQL statement
$sql = "SELECT * FROM subscribers ORDER BY email";
// execute the SQL statement
$result = mysql_query($sql, $conn) or die(mysql_error());
//go through each row in the result set and display data
while ($newArray = mysql_fetch_array($result)) {
// give a name to the fields
$id  = $newArray['id'];
$email = $newArray['email'];
//echo the results onscreen between ""can also //type$id is and &email is
echo " $email ";
}
?>
http://dev.mysql.com/doc/mysql/en/ALTER_TABLE.html
D
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] mysql results with limit

2004-09-04 Thread Doug Thompson
Michael Gale wrote:
Hello,
Right now I have a mysql select statement with the LIMIT option of 500.
Is there a way to find what the total number of selected results would
of been with out doing a mysql select first with out the limi and using
mysql_num_rows ?
Thanks
You could use SQL_CALC_FOUND_ROWS as it works somewhat differently, and probably 
faster, than the approach you suggest above.  This function was introduced in mysql 
4.0.0.
http://dev.mysql.com/doc/mysql/en/Information_functions.html
Doug
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] where can I post some mysql related questions?

2004-09-19 Thread Doug Thompson
Mike wrote:
hi, I've currently been looking for a mysql news server where I could post 
some questions on mysql database design (cause they shurely wouldn't fit 
here) and I have yet to find one. Can anyone help? 

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


Re: [PHP-DB] MultSelect ListBox hell!

2004-09-22 Thread Doug Thompson
Stuart Felenstein wrote:
I am in the process of building a search form for the
database.  The entire thing consists of 3 multi
selects and 2 text boxes with a "contains".  Oh and
I've only rigged 2 of the multi selects for the time
being.
So the way the multiselects should work that the user
can  choose one or the other or both, but the more
criteria provided back to the query , the more refined
the return. 

Here is the code and my tale of woe follows:($projects
is a just a holder / variable)
function BindEvents()
{
global $VendorJobs;
$VendorJobs->ds->CCSEvents["BeforeExecuteSelect"]
= "VendorJobs_ds_BeforeExecuteSelect";
}
//End BindEvents Method
//VendorJobs_ds_BeforeExecuteSelect @2-A4F75E44
function VendorJobs_ds_BeforeExecuteSelect()
{
$VendorJobs_ds_BeforeExecuteSelect = true;
//End VendorJobs_ds_BeforeExecuteSelect
global $VendorJobs;
$s_Industry = CCGetParam("s_Industry", "");
if (count($s_Industry) > 0 AND is_array($s_Industry))
{
foreach ($s_Industry as $key => $value) {
if ($Projects != "") $Projects = $Projects.",";
$Projects = $Projects."'".$value."'";
}
}
if ($Projects)
$VendorJobs->ds->SQL.= " AND (`VendorJobs`.Industry IN
(".$Projects."))";
$s_LocationState = CCGetParam("s_LocationState", "");
if (count($s_LocationState) > 0 AND
is_array($s_LocationState)) {
foreach ($s_LocationState as $key => $value) {
if ($Projects != "") $Projects = $Projects.",";
$Projects = $Projects."'".$value."'";
}
}
if ($Projects)
$VendorJobs->ds->SQL.= " AND
(`VendorJobs`.LocationState IN (".$Projects."))";
echo "SQL:". $VendorJobs->ds->SQL."";
return $VendorJobs_ds_BeforeExecuteSelect;
If you notice in the the SQL the "AND", I've changed
them back and forth to OR and a combo of AND in the
first and OR in the second.
If I have OR in both, then each multi works on it's
own, no refined / results.  If I have AND in both,
then they come together but if I try to add more
values (like a multi select should allow) I get a "no
records" return.
So something like this using in both AND:
I choose from Industry : Accounting and Finance
From LocationState: I choose Alabama
great it gives back to me all accounting and finance
records Alabama
But if I add in LocationState, Alabama and California
then a no records is returned.  

Anyway, if anyone has some pointers or ideas I'd
greatly appreciate.
Stuart

You need LocationState to be, in your example, Alabama OR California.  Also, I would write that 
SQL phrase  "LocationState = 'Alabama' OR LocationState='California' ".
Doug
Doug
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] parse error in php backend sqlite

2004-10-20 Thread Doug Thompson
Aravalli Sai wrote:
hi 
  this is php code for inventory management system
which is done using SQLite.this is an user
interface where an user wil giv values to the text
boxes and it should be saved in the backend database
which is sqlite..
but when i run this code on browser it is giving an
error ... Parse error: parse error in
/home/saravall/.HTML/inv.php on line 63






$db ="/home/saravall/office.db";
$handle = sqlite_open($db) or die("could not open
database");
if(isset($_POST['submit'])) {
if (!empty($_post['tagno']) && !empty
($_post['desc']) &&
!empty ($_post['acqdt']) && !empty
($_post['manufacturer']) && !empty
 ($_post['model']) &&!empty($_post['serialid']) &&
!empty( $_post
['custloc']) && !empty($_post['totcost']))
 {
$insquery = "insert into inventory
(tagno,desc,acqdt,manufacturer,model, serial
id,custloc,totcost) values (\"".sqlite_escape_string(
$_post['tagno'])."\",\"".sqlite_escape_string($_post['desc'])."\",\""
.sqlite_escape_string($_post['serialid'])."\",\"".sqlite_escape_string($_post
['custloc'])."\",\"".sqlite_escape_string($_post['totcost'])."\")";
 
 
$insresult = sqlite_query($handle,$insquery) or
die("error:".sqlite_error_string(sqlite_last_error($handle)));
echo "successfully inserted!";
}
else {
echo "incomplete from input!";
  $query = "SELECT * FROM inventory ";
$result = sqlite_query($handle,$query) or

die("err:".sqlite_error_string(sqlite_last_error($handle)));
if (sqlite_num_rows($result) > 0)
{
echo "";
while ($row = sqlite_fetch_array($result))
{
echo "";
echo "".$row[0]."";
echo "".$row[1]."";
echo "".$row[2]."";
echo "".$row[3]."";
echo "".$row[4]."";
echo "".$row[5]."";
echo "".$row[6]."";
echo "".$row[7]."";
echo "".$row[8]."";
echo "".$row[9]."";
echo "";
}
echo "";
}
sqlite_close($handle);
?>


i would appreciate if you can help me in correcting
this error..
thanks in advance..
sai
Your braces don't match up.  The problem starts at the ELSE statement in line 33.
Doug
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Problems with mysql_num-rows()

2004-10-31 Thread Doug Thompson
The variables are not being expanded. As a minimum, you need to escape the single quotes.
 $query = "SELECT * from user where name=\'$userid\' and 
pass=password(\'$password\')"

Alternatively, you can concatenate the expanded variables.
 $query = "SELECT * from user where name='".$userid."' and 
pass=password('".$password."')"

Good luck,
Doug
Arne Essa Madsen wrote:
I have the following problem:
This one does not work:
 $query = "SELECT * from user where name='$userid' and 
pass=password('$password')";
  $result = mysql_query($query, $link);
  $num_rows = mysql_num_rows($result);

I get this error message:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
resource in c:\wamp\www\fs1812_new\authmain.php on line 18

This one works OK:
  $query = "SELECT * FROM user";
  $result = mysql_query($query, $link);
  $num_rows = mysql_num_rows($result);
What is wrong and how can I use mysql_num_rows when the query include 
"WHERE"

A fast response will be very much appreciated.
Arne Essa Madsen;
[EMAIL PROTECTED] 

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


Re: [PHP-DB] MySQL problem..

2004-11-08 Thread Doug Thompson
ian wrote:
Any body met this error?
Warning: mysql_connect(): Client does not support authentication
protocol requested by server; consider upgrading MySQL client in
/usr/local/apache2/html/poems/browse.php on line 15
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] php newsletter with mysql data

2004-11-22 Thread Doug Thompson
Bishnu Prasad Dahal wrote:
Dear all,
I have to create a newsletter for a site 
http://www.migratetousa.com , I didn't code for any newsletter. could 
you suggest me how can I design the newsletter? And please send me 
sample php codes for newsletter 

Thanks,
Hame
I suggest you take a look at 
http://hotscripts.com/PHP/Scripts_and_Programs/index.html

They have several hundred scripts listed, some free - some not, that can help 
you complete your project quickly.
Doug
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] searching an entry in inventory db

2004-12-04 Thread Doug Thompson
Aravalli Sai wrote:
hi
  i had designed an inventory management system where
in i can ADD,INSERT,DELETE,UPDATE the data
elements..but when i am trying to find(search) an
entry in theinventory data base system (i want to find
the entrybased on the "tagno" since this is the
primary key in my table) the logic i had written is  

if(isset($_POST['submit'])) {
if (!empty($_POST['tagno']))
{
$insquery ="select
agno=(\"".sqlite_escape_string($_POST['tagno'])."\")
from 
inventory where
tagno=(\"".sqlite_escape_string($_POST['tagno'])."\")";
$insresult = sqlite_query($handle,$insquery) or
die("error:".sqlite_error_string(sqlite_last_error($handle)));
echo "successfully found!";
}
else
{
echo "not found!!!";
}
}

if i run this,it is giving me entire table ...but i
want only that particular row whose tagno i had
entered...
i would appreciate if anyone can figure out this...
What does $insquery contain when you echo it?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] select particular columns in query

2004-12-08 Thread Doug Thompson
The manual is your friend.
You cannot execute the SQL statement you provided because mysql specifically 
disallows it:
http://dev.mysql.com/doc/mysql/en/INSERT_SELECT.html
Same reference, your presumption about auto-increment columns is also wrong.
Doug
blackwater dev wrote:
Hello,
I want to create a new row in the db by copying an existing one.  My
db has an auto incrementing id so I can't simply do insert into cars
select * from cars where id=$id as this throws the primary key error. 
How can I do this with out specifying each column?

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


Re: [PHP-DB] List Active??

2004-12-29 Thread Doug Thompson
Dave,
The list has been very active with many posts per day all week.
Based on your domain, you might check with the sysops and see if they've done 
any updating to firewalls and/or corporate filters.
Good luck,
Doug
[EMAIL PROTECTED] wrote:
Just testing the list mail server as I haven't received any posts for days 
now.

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


Re: [PHP-DB] MySQL version issue

2005-01-04 Thread Doug Thompson
It seems to me that the _mysql manual_ gives a most straightforward and useful 
explanation:
"If you specify the ON DUPLICATE KEY UPDATE clause (new in MySQL 4.1.0), and a 
row is inserted that would cause a duplicate value in a UNIQUE index or PRIMARY KEY, 
an UPDATE of the old row is performed. For example, if column a is declared as 
UNIQUE and already contains the value 1, the following two statements have identical 
effect:
mysql> INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
mysql> UPDATE table SET c=c+1 WHERE a=1;
The rows-affected value is 1 if the row is inserted as a new record and 2 if an 
existing record is updated.
Note: If column b is unique too, the INSERT would be equivalent to this UPDATE 
statement instead:
mysql> UPDATE table SET c=c+1 WHERE a=1 OR b=2 LIMIT 1;
If a=1 OR b=2 matches several rows, only one row is updated! In general, you should 
try to avoid using the ON DUPLICATE KEY clause on tables with multiple UNIQUE 
keys."
Or, you might find a more interesting answer on a MySQL list.
Doug
Mark Benson wrote:
As some of you will recall, I enquired on this list about versions of MySQL and 
PHP a while back regarding and issue wit using the 'ON DUPLICATE KEY UPDATE' 
command in MySQL INSERT queries. Having upgraded our in-house system to PHP5 
and MySQL 4 the issue was no longer a problem.
However I have subsequently enquired with our out-of-house web host and they 
are still using PHP 4.1.2 and MySQL 3.25.58. As one of the purposes of asking 
them was to establish if I could easily upload from my database to the remote 
database, I now have a problem. I was planning to use a compare and update 
script that used 'ON DUPLICATE KEY UPDATE' command in MySQL INSERT queries to 
add or change items on the remote server. However I can't, as it's a MySQL4 
feature and the database to which I am writing ain't using MySQL4!
Any ideas about how I can create a MySQL3 compliant substitute for the 'ON 
DUPLICATE KEY UPDATE' Query action?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Re: MySQL version issue

2005-01-05 Thread Doug Thompson
I isn't my intention to start a peeing contest, but if *you* get rid of the 
chip and actually read the manual excerpt, the equivalent SQL statements it 
cites are very definitely available in mysql 3.xx.xx.
DT
Mark Benson wrote:
Doug, read my e-mail again, specifically the second and third paragraphs about 
what *version* of MySQL my host's server is using, then look at the manual 
entry again (specifically the first line you quoted).
The _mysql manual_ says... "If you specify the ON DUPLICATE KEY UPDATE clause (new 
in MySQL 4.1.0)" thus it only works in 4.1.0 and later, and my host is running MySQL 
3.23.58 (not 3.25.58 as I previously said, not that it makes much odds!). Anyhoo thanks 
for giving it a shot, RBR (read before replying) in future, there's a good chap ;o)
Bastien, thanks sometimes one needs a new perspectiuve on these things, I was 
stuck in my mysql_query brackets. Putting mind to matter using your tips it 
would actually be fairly simple to do that. Again thank you for providing an 
exit() to my stuck loop ;o)
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Integrating Interbase.so and PHP

2005-01-15 Thread Doug Thompson
Todd Cary wrote:
 I have compiled interbase.so, but even though I have
extension=interbase.so
in the php.ini file, it is not part of PHP.  Has anyone had success 
doing this?

Todd
A quick peek at the list archives (search term="interbase.so") revealed this:
http://marc.theaimsgroup.com/?l=php-db&m=107118069802473&w=4
Doug
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Given only one mySQL user account by Host Company

2005-01-23 Thread Doug Thompson
Simple _complete_ solution:  Find a different hosting company that provides a 
virtual server and root access to everything about your account.  Cost should 
be nominal, but probably not free.
Simple _partial_ solution:  Use INCLUDEs for the login portions of the 
script(s) and place them in a protected directory.  If you are unable to 
protect directories (.htaccess) with this host, they are begging for trouble 
and victimizing their subscribers.
Simple _lack of a_ solution:  Don't put anything on this site that anyone cares 
about protecting.
If that all sounds obvious, it's supposed to.
Doug
Shay wrote:
My hosting company gave me one database and one root user account, and I 
have no access for priviliges at all. So as far as I can tell, the only way 
for me to connect to the database on my site is to do a 
mysql_connect("host", "user", "pass"), where the user and pass are the ones 
for this one super account.

Is this a major security concern or what? Is there a way around this, or a 
way to minimize security problems? I've emailed them about this, and they 
act like they have no clue what I'm talking about:


I'm not trying to hide files or directories, I'm talking about when I use
PHP and make a connection to the database using mysql_connect("host",
"user", "pass"). This script is what is in my webpages that connects to the
DB and retrieves data to print for users. Is there an anonymous account to
use for retrieving data, or can I make one?

Then the program or script you are using should have means
for your users to access permitted areas. And there is no
anonymous account, there is only your own account Db
Now. Hosting company provide your site with tool for you to use your
own programs and it's up to you which programs and how you use them.
Our job is to make sure the tool is working. Other than that, we do not
provide support for scripts and the programs you are using.
If you having problems to use some programs then you need to get
in touch with developers and find what need to be done and how. 

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


Re: [PHP-DB] Given only one mySQL user account by Host Company

2005-01-23 Thread Doug Thompson
Shay wrote:
Yes they gave me phpMyAdmin to use, and no, I have no access to the 
user/privilege table. So the only way to output database entries is to 
connect with the single super account they gave me.

Principally, this means you cannot allocate user accounts for mysql.  No 
big deal unless you have a business model that calls for that.  In which case, 
refer to my first comment in my original reply.
I have a question about what you said Doug:

Use INCLUDEs for the login portions of the script(s) and place them in a 
protected directory.  If >you are unable to protect directories (.htaccess) 
with this host, they are begging for trouble and >victimizing their 
subscribers.

In other words, call on an external function to connect to the database, and 
place the file with this function in a directory that is .htaccess 
protected. Is this correct? I do have a separate file with a database 
connect function that all the pages on my site use, I just don't have it in 
a .htaccess protected directory. 

Exactly right. The objective is to make it more difficult to hack the mysql 
login info.
Doug
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Given only one mySQL user account by Host Company

2005-01-23 Thread Doug Thompson
Without the ability to update the database "mysql", your suggestion doesn't 
work.
Just to confirm, here is a quick check to perform locally.
1.  Log in as root.
2.  Create DB "test" and user "test" with all privileges with grant option on only database "test".
   (grant all privileges on test.* to 'test'@'localhost' identified by 'password' with grant option;)
3.  Log out and reconnect with userid 'test'.  Note that your top level db is now "test".
4.  Create a table "testtable" in db "test"
5.  Attempt to create new user "foo" with (any) privileges on test.testtable.  
   You will receive the following error message:   "Error Code : 1044
   Access denied for user: '[EMAIL PROTECTED]' to database 'mysql'"

Shay is in the same boat as user "test."
Doug
Bastien Koert wrote:
Another thought on this:
Even though you don't have access via phpmyadmin to get to the users 
table, could you try to create users/grant privileges via straight sql 
thur the PMA sql window?

ie
grant select, insert, update to 'bob'@'localhost' on mysql.users 
indentified by password('my_pass');

bastien

From: Doug Thompson <[EMAIL PROTECTED]>
To: Shay <[EMAIL PROTECTED]>
CC: php-db@lists.php.net
Subject: Re: [PHP-DB] Given only one mySQL user account by Host Company
Date: Sun, 23 Jan 2005 15:51:41 -0700
Shay wrote:
Yes they gave me phpMyAdmin to use, and no, I have no access to the 
user/privilege table. So the only way to output database entries is 
to connect with the single super account they gave me.

Principally, this means you cannot allocate user accounts for mysql.  
No big deal unless you have a business model that calls for that.  In 
which case, refer to my first comment in my original reply.

I have a question about what you said Doug:

Use INCLUDEs for the login portions of the script(s) and place them 
in a protected directory.  If >you are unable to protect directories 
(.htaccess) with this host, they are begging for trouble and 
>victimizing their subscribers.


In other words, call on an external function to connect to the 
database, and place the file with this function in a directory that 
is .htaccess protected. Is this correct? I do have a separate file 
with a database connect function that all the pages on my site use, I 
just don't have it in a .htaccess protected directory.

Exactly right. The objective is to make it more difficult to hack the 
mysql login info.

Doug
--
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] Checking if number is in bottom three?

2002-12-23 Thread Doug Thompson
Generally, you want to use the LIMIT function.

SELECT num FROM myfile ORDER BY num LIMIT 3;

However, if the values may be repeated (e.g., 1,1,1,2,4,4,5), the query
above will return 1,1,1.
If you are interested in the three lowest values and not just smallest
entries, add DISTINCT

SELECT DISTINCT num FROM myfile ORDER BY num LIMIT 3;
  which will return 1,2,4

I hope this answers your question.

Merry Christmas,
Doug



On Mon, 23 Dec 2002 11:13:31 -0500, Leif K-Brooks wrote:

>I need a way to check if a number is in the bottom three of a column in 
>my database.  For example, if I had a list of number in my table like this:
>1
>5
>8
>12
>60
>1
>10001
>I might need to know if 5 was in the bottom three, which it would be. 
> But if I checked 60, it wouldn't be.  I could check the lowest number 
>and add 3 to it, but it may have gaps.  Any ideas?
>
>-- 
>The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
>to decrypt it will be prosecuted to the full extent of the law.
>
>
>
>-- 
>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 and MySQL

2002-12-25 Thread Doug Thompson
The simplest solution is to edit php.ini on your Linux box and set the
parameter register_globals to ON.  As of PHP4.2.0 the default setting
is OFF and new "super globals" are available.
A better solution is to update your windows box to the same version of
PHP so that you are programming to the improved security properties.

Here is a good article to explain what's going on and point you to even
more info:
Title:  Coding PHP with Register Variables OFF

http://www.zend.com/zend/art/art-sweat4.php

hth,
Doug


On Wed, 25 Dec 2002 13:22:20 +0100, JabMaster wrote:

>Hello,
>
>I have created a website (www.mirax.cz) with a database mysql 3.23.33 and used PHP 
>4.0.4pl1. Everything functions perfect ONLY at my W98. As soon as I want to use the 
>same database exported to linux(PHP 4.2.2) or w2000(PHP 4.2.3) both with mysql 
>3.23.54, it has problems like this:
>
>Notice: Undefined variable: kategorie in c:\inetpub\wwwroot\mirax\search\search.php 
>on line 37
>even if  "kategorie"  IS defined and the same PHP script works in w98, PHP 4.0.4pl1
>
>
>In w2000 even my simple contact form (NOT USING THE DATABASE) is giving me the same 
>error:
>Notice: Undefined variable: jmeno in c:\inetpub\wwwroot\jab\kontakt.php on line 3 - 
>even if  "jmeno" is defined and this form works in w98, PHP 4.0.4pl1
>
>
>
>
>WHAT SHOULD I DO ??
>
> 
>Thank you for any suggestions.
>
>
>
>jab
>
>
>
> 



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




Re: [PHP-DB] php and mysql on RH8.0

2002-12-29 Thread Doug Thompson
1.  Is mysqld running?  I don't remember if the default configuration
for RH8.0 sets it to start on system boot.

The easy way to check is:

ps aux | grep mysql

or

mysqladmin -u root ping

will return "MySQL is alive" if the server is running.

2.  See chapter 2.4 of the MySQL Manual for Post-installation Setup and
Testing

http://www.mysql.com/doc/en/Post-installation.html

hth,
Doug

On Sun, 29 Dec 2002 16:46:38 +0100 (CET), franco stridella wrote:

>
>Hi,
>
>i apologize in advance for my stupid question. I installed RedHat8.0 with built in 
>apache 2 and php 4.2.2
>
>By looking at phpinfo() i see that php has been compiled with --with-mysql,shared and 
>php works but it seems that mysql is not enabled. Why? how can i use mysql with php? 
>what have i to enable to make it run?
>
>bye



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




RE: [PHP-DB] php variables to JS

2003-01-05 Thread Doug Thompson
OK.  I consider this an easier way.  I use it to display fullsize
images when a thumbdnail is clicked.  Same principle.

>From 


var pixNum="",winName="", mheight="", mwidth=""

var pixURL="http://**someURL**/";

function viewPix(pixNum,winName,mheight,mwidth) {
 win =
window.open(pixURL+pixNum,winName,"status=no,toolbar=no,location=no,menu
=no,scrollbars=yes,resizable=yes,width="+ mwidth + ",height=" + mheight
+'"');
}



>From 

(snip...)

 




(snip ...)


This is used to display a large image after clicking on a thumbnail. 
The principle is the same regardless what you want to pass to the
scripts.

Hope there is some inspiration here.

Regards,
Doug


On Sun, 5 Jan 2003 09:35:04 -0500, Rich Hutchins wrote:

>>From what I have learned PHP and JS don't "talk" directly to each other.
>Instead, you have to make hidden fields in your html that hold the values
>from your database then access those hidden fields with JS. If you want to
>take values from JS and use them in a PHP script, then the process is
>reversed; make hidden fields, set their values with JS then pass the hidden
>fields to a PHP script.
>
>In your case the relevant (abbreviated and untested) PHP code might look
>like this:
>   //where $dbWindowHeight is avariable that has been assigned a value from
>your dbquery
>   echo "".
>   "".
>   "";
>?>
>
>The relevant JS might look something like this:
>var height = document.form.windowHeight.value;
>
>Then for your window.open JS call, you'd substitute the var named height
>into the string with the rest of the chromeless information.
>
>If anybody knows an easier way, please post it because I'd love an easier
>alternative if one exists.
>
>Hope this helps. If not, I know there's a wealth of info in the PHP archives
>about this subject. That's where I learned.
>
>Rich
>
>-Original Message-
>From: Bruce Levick [mailto:[EMAIL PROTECTED]]
>Sent: Sunday, January 05, 2003 2:09 AM
>To: [EMAIL PROTECTED]
>Subject: [PHP-DB] php variables to JS
>
>
>Bruce Levick - VivamotionI am opening a chromless window with some JS code.
>I need to pass some variables which come from rows in my database into the
>jscript which will determine the size and URL of the window.
>
>Before I go about drawing the info from the database I have set up some hard
>code php variables just so i could test how to pass these into js.
>
>Does anybody know how I can code these variables into my jscript??
>
>Cheers
>
>##
>$h = 600;
>$w = 343;
>$theURL = test.php;
>$wname = test;
>?>
>###
>
>##
>SRC="js/java.js">
>
>
>
>
>##
>
>
>
>--
>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
>



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




Re: [PHP-DB] If select query doesn't net any results

2003-01-09 Thread Doug Thompson
...
if ($result) {
while ($row...
...
}

$result will be 0 (false) if nothing satisfies the query.  Any other
comparison is just extra typing with no improvement in logic.

Regards,
Doug


On Thu, 09 Jan 2003 13:06:51 -0500, Michael Cortes wrote:

>I am a programming novice and just created my first php application.  However I have 
>a situation I 
>don't know the answer to.
>
>
>My db queries (mysql) are written like this:
>
>   $qtrans= "select * from $table where (conditionals) order by some field";
>
>   $link=mysql_connect ($host, $user, $password);
>
>   $result=mysql_db_query($dbname, $qtrans, $link);
>
>   while ($row = mysql_fetch_array($result))   {
>
>   do stuff with the array here
>   
>   }
>
>
>
>I would like to created an if statement that only occurs if the query gets a result.  
>If there are 
>no records that meet the query conditionals and my array ends up with null, I do not 
>want my if 
>statement to take place.
>
>Is this easy enough to do?  Any help would be great.
>
>Thank you,
>
>
>
>
>Michael Cortes
>Fort LeBoeuf School District
>34 East 9th Street
>PO Box 810
>Waterford PA 16411-0810
>814.796.4795
>Fax1 814.796.3358
>Fax2 978-389-1258





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




RE: [PHP-DB] If select query doesn't net any results

2003-01-09 Thread Doug Thompson
You're absolutely right.
It must be the 1.5 hours of sleep last night that made my brain shrivel
up like that. 8(

Doug

On Thu, 9 Jan 2003 17:45:00 -0500, John W. Holmes wrote:

>> ...
>> if ($result) {
>>  while ($row...
>>  ...
>> }
>> 
>> $result will be 0 (false) if nothing satisfies the query.  Any other
>> comparison is just extra typing with no improvement in logic.
>
>No, it only returns false/0 if the query fails, meaning there was an
>error and the query couldn't be executed. The query can execute just
>fine, return no rows, and so the result would be true. 
>
>What you have is extra typing with no improvement in logic. ;)
>
>If you need to know the number of rows returned, then use the
>if(mysql_num_rows() method. If you don't, then you can do this:
>
>if($row = mysql_fetch_row($result))
>{
>   do{
>   //do whatever with $row data
>   }while($row = mysql_fetch_row($result));
>}
>else
>{ echo "no rows returned from query"; }
>
>If you simply do not want something done if no rows are returned, then
>the simple while($row = mysql_fetch_row($result)) method works fine, as
>the while() will only be true if rows were returned and skipped if no
>rows are returned.
>
>---John W. Holmes...
>
>PHP Architect - A monthly magazine for PHP Professionals. Get your copy
>today. http://www.phparch.com/
>
>



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




Re: [PHP-DB] db connect probs

2003-01-15 Thread Doug Thompson
MySQL cannot find the username in its grant tables.

The error message very clearly states that there is no user named
'x,@host' which is the value of your $user variable.  For your example,
$email == 'x' and $femail == '@host'.  The comma is included because it
is part of the literal string, i.e., inside the double quotes.

hth,
Doug

On Tue, 14 Jan 2003 22:08:11 -0600, Addison Ellis wrote:

>hello,
>   do you have any idea why the following(line 106)would return 
>the following
>error message ?  the login.php has an included form to create an 
>account and that is what will not connect.
>
>$connection = mysql_connect($host, $user,$password) //this is line 106
>
>Warning: Access denied for user: 'x,@host' (Using password: YES) in 
>/users/infoserv/web/register/login.php on line 106
>
>Warning: MySQL Connection Failed: Access denied for user: 'x,@host' 
>(Using password: YES) in /users/infoserv/web/register/login.php on 
>line 106
>Couldn't connect to server.
>
>my required file is as follows:
>  $user="$email,$femail";
>  $host="$hostname";
>  $password="password('$password'),password('$fpassword')";
>  $database="$classes";
>?>
>
>
>thank you again for your time. addison
>-- 
>Addison Ellis
>small independent publishing co.
>114 B 29th Avenue North
>Nashville, TN 37203
>(615) 321-1791
>[EMAIL PROTECTED]
>[EMAIL PROTECTED]
>subsidiaries of small independent publishing co.
>[EMAIL PROTECTED]
>[EMAIL PROTECTED]



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




Re: [PHP-DB] Secure variable transport (newbie)

2003-01-23 Thread Doug Thompson
Here is a link to a tutorial which explains the issues and introduces
how
to use the new global variables.

Write Secure Scripts with PHP 4.2!
http://www.webmasterbase.com/article/758

Regards,
Doug

On Thu, 23 Jan 2003 00:30:24 +0100, Karina S wrote:

>Hi,
>
>I have read, that use global variables on php site is not a good idea. I'm
>newbie in PHP and maybe a stupid question:
>If I make an array and register it in a session and after I use it all of my
>pages as $HTTP_SESSION_VARS['variable'] and register_globals is off. In this
>case is $HTTP_SESSION_VARS['variable'] a global variable?
>
>What is the best method (most secure method) to use the same array on all
>php site? (I want to read the user data, but don't want to read it always
>from database. I want to read once and use it on more pages. )
>
>Thanks for your help!
>
>
>
>
>-- 
>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] update

2003-02-04 Thread Doug Thompson
UPDATE is for changing values in existing rows.  It appears you want to
add new information.  Use INSERT.

$query= "INSERT tablename SET (username, email, location) VALUES(
$username, $email, $location)";
Note that a WHERE condition is incorrect for INSERT.

Your UPDATE syntax is not correct either.  Note that you need only one
query to update any or all of the columns in a row.

Using your example:

$query="UPDATE tablename SET username=$username, email=$email,
location=$location WHERE userID=$id";

Finally, your "Flash of Success" is not useful because it will print
even when the query fails.

Doug

On Thu, 30 Jan 2003 13:34:41 -0500, Ike Austin wrote:

>Hello, Newbie question.
>
>And can the same SQL portion of the code be written something like...
>query= "UPDATE taablename SET (username, email, location)
>VALUEs( $username, $email, $location)";
>
>Any reason why this Update command would not execute?
>
>// BUILD AND EXECUTE QUERY TO SAVE USER INFO INTO DATABASE TABLE
>query = "UPDATE forumUsers SET username = '$name' WHERE userID = '$id'";
>result = @mysql_query($query);
>query2 = "UPDATE forumUsers SET email = '$emai' WHERE userID = '$id'";
>result2 = @mysql_query($query2);
>query3 = "UPDATE forumUsers SET Location = '$loc' WHERE userID = '$id'";
>result3 = @mysql_query($query3);
>
>/ INFORM FLASH OF SUCCESS
>print "&/:result=Updated Thanks";
>// CLOSE LINK TO DATABASE SERVER
>ysql_close($link);
>?>
>
>
>Ike



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




Re: [PHP-DB] update

2003-02-04 Thread Doug Thompson
INSERT ... SELECT is for inserting values from another table into the
current one.  That is a different circumstance than what was described
in the original inquiry.

http://www.mysql.com/doc/en/INSERT.html


On Tue, 4 Feb 2003 14:32:45 +0100, Ignatius Reilly wrote:

>If you want to use WHERE clause, see the
>
>INSERT table
>SELECT ...
>
>syntax.
>
>Extremely convenient. You inherit all the flexibility of the SELECT
>statement.
>
>Ignatius
>
>----- Original Message -
>From: "Doug Thompson" <[EMAIL PROTECTED]>
>To: "Ike Austin" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
>Sent: Tuesday, February 04, 2003 2:17 PM
>Subject: Re: [PHP-DB] update
>
>
>> UPDATE is for changing values in existing rows.  It appears you want to
>> add new information.  Use INSERT.
>>
>> $query= "INSERT tablename SET (username, email, location) VALUES(
>> $username, $email, $location)";
>> Note that a WHERE condition is incorrect for INSERT.
>>
>> Your UPDATE syntax is not correct either.  Note that you need only one
>> query to update any or all of the columns in a row.
>>
>> Using your example:
>>
>> $query="UPDATE tablename SET username=$username, email=$email,
>> location=$location WHERE userID=$id";
>>
>> Finally, your "Flash of Success" is not useful because it will print
>> even when the query fails.
>>
>> Doug
>>
>> On Thu, 30 Jan 2003 13:34:41 -0500, Ike Austin wrote:
>>
>> >Hello, Newbie question.
>> >
>> >And can the same SQL portion of the code be written something like...
>> >query= "UPDATE taablename SET (username, email, location)
>> >VALUEs( $username, $email, $location)";
>> >
>> >Any reason why this Update command would not execute?
>> >
>> >// BUILD AND EXECUTE QUERY TO SAVE USER INFO INTO DATABASE TABLE
>> >query = "UPDATE forumUsers SET username = '$name' WHERE userID = '$id'";
>> >result = @mysql_query($query);
>> >query2 = "UPDATE forumUsers SET email = '$emai' WHERE userID = '$id'";
>> >result2 = @mysql_query($query2);
>> >query3 = "UPDATE forumUsers SET Location = '$loc' WHERE userID = '$id'";
>> >result3 = @mysql_query($query3);
>> >
>> >/ INFORM FLASH OF SUCCESS
>> >print "&/:result=Updated Thanks";
>> >// CLOSE LINK TO DATABASE SERVER
>> >ysql_close($link);
>> >?>
>> >
>> >
>> >Ike
>>
>>
>>
>> --
>> 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
>



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




Re: [PHP-DB] Remnant data from previous queries when using mysql_fetch_array...

2003-02-06 Thread Doug Thompson
Try getting the results from the query like the following.

Doug


// generate and execute query
$query = "select * from changelog where changedBy = '$changedBy' or
vendorNumber = '$vendorNumber'
or oldName like '$oldName' or newName like '$newName' or
newVendorNumber =
'$newVendorNumber'";
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());

//
$numrows = mysql_num_rows ($result)

if ($numrows) {
while ($row = mysql_fetch_array($result)) {
   print "Old vendor number: ";
   print $row["vendorNumber"];
   print "";
  }  //end while

//


} else {print "Sorry, no records were found!";}

// close database connection
mysql_close($connection);

On Thu, 6 Feb 2003 11:41:30 -0500, Mike Hilty wrote:

>Okay, I figured out that the issue is not due to the PHP code, but by the
>query I'm using against the MySQL DB...
>
>What I need to know is how to structure the code where the query is based
>off of fields filled in by the user.  I would like to structure the query
>where if the user provides a value for vendorNumber, and leaves the rest of
>the fields blank, the query would be "select * from changeLog where
>vendorNumber = '$vendorNumber';"
>
>The current query, when run in MySQL Control Center, gives the same behavior
>as on the website.
>
>Would I have to write this portion of the code in javascript, or some other
>client side scripting language to get the dynamic query built?
>
>Thanks,
>Mike Hilty



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




Re: [PHP-DB] Remnant data from previous queries when using mysql_fetch_array...

2003-02-06 Thread Doug Thompson
On Thu, 06 Feb 2003 10:33:23 -0700, Doug Thompson wrote:

>Try getting the results from the query like the following.

-snip-
With the correct syntax.  8-(
Doh!

>
>//
>$numrows = mysql_num_rows ($result);
>   ^



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




Re: [PHP-DB] sorting values

2003-02-10 Thread Doug Thompson
Merlin:

You might find it easiest to CREATE a temporary table.
You can use an INSERT .. SELECT query to extract the values from your
data tables and insert them in the temp table.
Then you can SELECT from the temporary table and use all of the SQL
functions for ordering, grouping, etc.

Doug

On Mon, 10 Feb 2003 15:14:55 +0100, merlin wrote:

>Hello everybody,
>
>I am pulling out several values out of a mysqldb. Those come with different
>tables and different criterias, thats why I cant sort them inside the sql
>statement. I need to make 3 of those statements.
>All the different results have an associated timestamp. How could I sort
>them after pulling out the values into variables (sort after time desc)?
>
>for esample:
>new user pictures  time 10:00:00
>new user articles   time 12:00:00
>new whatever   time 11:00:00
>
>thanx for any help,
>
>merlin
>
>
>
>-- 
>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] question about access

2003-02-10 Thread Doug Thompson
If your client's friend wants to do learning/development, let him load
PHPTriad, FoxServ, or one of the other trinity setups onto his
computer.

It is truly remarkable that you/your company would even consider such a
request for longer than it takes to say: Never in a million years.

Also, if I were running security at your site, I would closely monitor
that client's activities on the system assuming that's how you are set
up.  That is a loose cannon out there.

Doug

On Mon, 10 Feb 2003 10:29:18 -0600, Terry Romine wrote:

>I'd like to get some opinions from the list.
>
>We run php/mysql on our linux servers located behind a firewall. Many 
>of our clients have scripts that access their databases via php running 
>on the hosting server, and the general access is set up as:
>
>   $hostname = "localhost";
>   $database  = "clientsDB";
>   $username = "client";
>   $password = "";
>
>   etc..
>
>One of our clients has a friend who wants to do some php/mysql and has 
>asked for access to the database. We gave them the information above, 
>and he complains that "localhost" is insufficient. We think that if he 
>is requesting "servername.domain.net:accessPort" that that gives him 
>access through the firewall. Instead, he should upload his scripts 
>using ftp and use localhost, as all our other clients do.
>
>What is the general consensus?
>
>If giving an outsider this kind of access just asking for trouble?
>
>Terry



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




Re: [PHP-DB] Question about replacing large textfields

2003-02-14 Thread Doug Thompson
http://www.hotscripts.com/PHP/

One example:
http://www.hotscripts.com/Detailed/9026.html

Good luck,
Doug

On Fri, 14 Feb 2003 16:09:34 +0100, Ingen, Wart van wrote:

>Hi there,
> 
>I'm looking for a way to let people without any knowledge of coding replace
>large fields of text and images on their website.
>Is there anyone who knows some way to do this with MySQL and PHP ? Maybe
>someone knows where I can find an online 
>tutorial about this?
> 
>Thanks a bunch
>



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




Re: [PHP-DB]

2003-02-18 Thread Doug Thompson
Nikos:

The mysql.sock file is created by mysqld when it is running.
The error you report is very common and you will find troubleshooting
tips at:
http://www.mysql.com/doc/en/Can_not_connect_to_server.html

Doug

On Tue, 18 Feb 2003 10:18:42 +0200, nikos wrote:

>GlacierHi List
>I run mysql 3,23.. in a RH 7.2 Linux web server.=20
>Sudenly mysql crash and non of my db's runnig. Mysqld (re) starts [OK].=20
>The message in my browser is that mysql.sock file is missing
>Does knows why? What is this file?
>Thanx
>
>
>
>



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




Re: [PHP-DB] Random not working?

2003-03-01 Thread Doug Thompson
This recent thread from the mysql list explains a lot about the
problem.
http://lists.mysql.com/cgi-ez/ezmlm-cgi?1:mss:15034


hth,
Doug

On Sat, 1 Mar 2003 12:24:57 +0100, Frank Keessen wrote:

>Hi All,
>
>I'm trying to get a random record each time this script runs; Only it's giving me 
>everytime the first record back.. No random at all..
>
>// generate and execute query
>$query = "SELECT stedenid, naamstad, stadomschrijvk FROM steden ORDER BY RAND() LIMIT 
>1";
>$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
>$row = mysql_fetch_object($result);
>echo $row->naamstad;
>
>
>Version info;
>
>PHP 4.3.1
>Mysql 3.23.54 
>
>When i'm trying to excute the SELECT statement in phpmyadmin; i'm only getting the 
>first record back and when i'm taking off the LIMIT 1 it will display all the records 
>in ascending order so also not in random..
>
>
>Regards,
>
>Frank
>
>
>
>
>
>



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



Re: [PHP-DB] Re: sorting results in PHP

2003-03-18 Thread Doug Thompson
Without knowing your query, it is hard to say whether mysql can return the results you 
want.

However, you can GROUP BY and SORT BY multiple columns in a single query.  The 
following simple query returns a subset of property owners grouped by lastname, 
alpabetized by group, and ordered by zipcode from a database I have at hand.  Mysql 
Version 4.0.1a

select last_name, zipcode from mytable where last_name like "sm%" group by last_name, 
zipcode order by last_name, zipcode;


You could simplify your life by combining your y,m,d fields into a single DATE type, 
too.

Doug


On Tue, 18 Mar 2003 10:36:40 +0200, Edwin Boersma wrote:

>What about making an array with dates, that you compiled from Year, 
>Month, Date using mktime(), and sort that?
>
>Edwin
>
>Bill wrote:
>> I have a query that returns results including the fields Year, Month, and Day
>> that I want to sort by date.
>> 
>> Because of the nature of the query (it includes a GROUP BY statement), I cannot
>> sort it in the query.
>> 
>> How can I sort the results?
>> 
>> I tried to use asort() while designating the field but that didn't work.
>> 
>> while ($crow=mysql_fetch_array($cresult)) {
>>   $therow[]=$crow;
>> }
>> asort($therow["Year"]);
>> reset($therow);
>> asort($therow["Month"]);
>> reset($therow);
>> asort($therow["Day"]);
>> reset($therow);
>> 
>> ideas?
>> 
>> kind regards,
>> 
>> bill
>> 
>
>
>-- 
>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] multiple connections to MySQL in a single script example

2003-03-30 Thread Doug Thompson
You will use the mysql_select_db() function. It sets the currently active database.  
You will call this function each time you wish to change which database is being used 
prior to issuing a query. 

You need to open only one connection as long as the databases are on the same server.  
If you are using multiple servers, you will require a connection to each with unique 
resource link_identifiers.  Then you will have to include the desired resource link_id 
in each call to mysql_select_db().  There is no need to close and re-open connections 
between each use.

Doug


On Sat, 29 Mar 2003 19:09:28 -0800 (PST), Lonnie Cumberland wrote:

>Hello All,
>
>I am new to using PHP with MySQL and was wondering if anyone had a simple
>example of how to have multiple active connections to two MySQL databases in a
>single script?
>
>I will have to access two different databases but am not sure how to keep the
>active connections and make different queries to each one without having to
>open one database, make a query, close it, then open the other database and 
>make it's query.
>
>This should be possible I think.
>
>Any help would be greatly appreciated,
>Lonnie Cumberland
>
>
>__
>Do you Yahoo!?
>Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
>http://platinum.yahoo.com
>
>-- 
>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] Starting to hate MySql... thinking about using MS Sql Server instead...... :-(((((((((

2003-03-30 Thread Doug Thompson
There's nothing like RTFM to douse the fire in a rant.


4.2.3 Startup Options for mysqld Concerning Security
The following mysqld options affect security: 

--local-infile[=(0|1)] 
If one uses --local-infile=0 then one can't use LOAD DATA LOCAL INFILE. 


This setting has been defaulted to 0 in recent releases.  You can read more than you 
probably want to here:
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql

PHHPmyadmin is a good gui, but I prefer sqlyog which you'll find at 
http://www.webyog.com/

hth,
Doug


On Sun, 30 Mar 2003 13:46:23 -0700, Sparky Kopetzky wrote:

>ARGGHHH!!!
>
>Trying to use INFILE to load a small (125) entry block of data and all MqSql does is 
>puke:
>
>ERROR 1148: The used command is not allowed with this MySql version. (3.23.55)
>
>If this command is no good, then what the hell am I supposed to use
>
>At least with MS, you have a nice, GUI to use...
>
>Robin Kopetzky
>Black Mesa Computers/ISP
>



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



Re: [PHP-DB] Re: [PHP] mysl_connect question

2003-04-05 Thread Doug Thompson
The access denied message you are seeing is usually the result of either an incorrect 
password or username, but you don't give enough information to allow guessing beyond 
that.

 Are you certain your script is submitting the expected values?

Doug

On Sat, 05 Apr 2003 21:54:33 -0600, [EMAIL PROTECTED] wrote:

>Thanks for you help!
>
>First I tried flush privileges and I have tried to reboot mysql.  I am
>running into a problem if I use user @localhost or @mysite.com.  I have
>tried setting up the user with both those domains inside both mysql.User and
>mysql.db.  I have used [EMAIL PROTECTED] or [EMAIL PROTECTED] both with success.
>
>I can still connect on the command line but not using mysql connect, I get
>the following error:
>
>Warning: Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) in
>3rdpage.php on line 123
>
>I'm at a loss...
>
>/T
>
>PS: sorry about the cross posting, it won't happen again...
>
>
>on 4/5/03 3:04 PM, Jim Lucas at [EMAIL PROTECTED] wrote:
>
>> did you reload mysql so it will have the new user?
>> 
>> Jim
>> - Original Message -
>> From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
>> To: "php mailing list list" <[EMAIL PROTECTED]>
>> Sent: Saturday, April 05, 2003 10:40 AM
>> Subject: [PHP] mysl_connect question
>> 
>> 
>>> When I use myssql to connect to a db with anything besides root I get an
>>> error that I cannot connect.  I created a user that has access to one
>>> databse called 'menu'. The user has SELECT, UPDATE, and DELETE permissions
>>> for that database.
>>> 
>>> I can connect on the command line: mysql-u newuser -p.  But no luck using
>>> mysql_connect().
>>> 
>>> Anyone have this problem?
>>> 
>>> 
>>> .T
>>> 



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



RE: [PHP-DB] Can't do anything with variables

2003-04-06 Thread Doug Thompson
Unlike Luke, I'm not familiar with this book.  However, it's a pretty safe bet that it 
was written prior to the first version of PHP that defaulted register_globals to OFF.

All of your variables for the second page will be found in the global array $_POST[] 
because the method for the form on the first page is POST.

If you are developing on a private system, you can set register_globals ON in php.ini 
so that what you are learning will follow the book.  As soon as you get a bit more 
experience, turn the register_globals back off and revise your scripts to work with 
the global arrays.  The revision needs to be nothing more than a series of statements 
near the beginning of a page to initialize the local variables to the global array 
values.  For example,

$searchtype = $_POST['searchtype'];
... etc. ...

Then the rest of your script(s) should work as written.

Enjoy,
Doug

--Original Message Text---
From: Luke Woollard
Date: Mon, 7 Apr 2003 11:34:01 +1000

Dude - sweet book. I bought it myself when i was starting out.

Your problem is due to the PHP error message setting in the php.ini file.

Whack this at the beginning of your scripts:


// Report simple running errors
error_reporting  (E_ERROR | E_WARNING | E_PARSE);



When you know more - check out the php.ini file and read about the error
level..
And this page in the PHP manual:
http://www.php.net/manual/en/function.error-reporting.php

Cheers,

Luke Woollard





-Original Message-
From: Gilles [mailto:[EMAIL PROTECTED]
Sent: Monday, 7 April 2003 11:18 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Can't do anything with variables


Hi all,

Sorry for this really beginner question (PHP-Newbie here). I bought the book
"PHP and MySQL web developpement" (Welling & Thompson) and I'm trying to
recreate the exemples and it won't work. I installed PHP 4.3.1 and MySQL
4.0.12.

The easy part. Here's a simple form page (from the book):
SEARCH.HTML
Book-O-Rama Catalog Search 

Book-O-Rama Catalog Search

Choose Search Type:
Author Title ISBN 
Enter Search Term:



And now the processing page:
RESULTS.PHP
Book-O-Rama Search Results 

Book-O-Rama Search Results

Number of books found: ".$num_results.""; for ($i=0; $i ".($i+1).". Title: "; echo 
stripslashes($row["title"]); echo "
Author: "; echo stripslashes($row["author"]); echo "
ISBN: "; echo stripslashes($row["isbn"]); echo "
Price: "; echo stripslashes($row["price"]); echo ""; } ?> 

The problem. Even if I fill both fields, I always get "Notice: Undefined
variable: searchtype"

The only way it would work is if I remove all the "if" part and leave the
"select * from books" (without the where clause).

I don't get it. Any help would be much appreciated.

Regards

Gilles


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




Re: [PHP-DB] HELP, Still not be able to connect to MySQL

2003-06-12 Thread Doug Thompson
Your IP users have no permissions.  (Hint:  N = No)

How is this a PHP problem?  (Hint: It is all over the mysql list archives.)

Doug


On Thu, 12 Jun 2003 13:35:21 +0300, nabil wrote:

>GUYS help me please.
>1- mysql server in on my own machine..
>2- my machine IP is 192.168.0.1
>3- when i tired to connect as localhost, i managed to query.
>4- if i tried to to connect using my IP i got "no database found"...
>5- i tried to use mysql_error() ... and it is not an authentication problem
>as my fresh Mysql sitting point to :
>
>#
># Dumping data for table `user`
>#
>
>INSERT INTO user VALUES ('localhost', 'root', '', 'Y', 'Y', 'Y', 'Y', 'Y',
>'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');
>INSERT INTO user VALUES ('%', 'root', '', 'N', 'N', 'N', 'N', 'N', 'N', 'N',
>'N', 'N', 'N', 'Y', 'N', 'N', 'N');
>INSERT INTO user VALUES ('localhost', '', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y',
>'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y');
>INSERT INTO user VALUES ('%', '', '', 'N', 'N', 'N', 'N', 'N', 'N', 'N',
>'N', 'N', 'N', 'N', 'N', 'N', 'N');
>
>so it should accept any host.!!!
>
>6- even i tried from other machine on my local network (from 192.168.0.2) i
>still not be able too...
>
>Please help me, am i missing to point to a port number ???
>*** all the above is to test how to connect to a remote Mysql server
>online...
>
>Nabil
>
>
>
>-- 
>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] Select statement drops 10th digit during table lookup?

2003-06-13 Thread Doug Thompson
Why not use the built-in conversion functions in mysql?

>From the manual:

INET_NTOA(expr) 
Given a numeric network address (4 or 8 byte), returns the dotted-quad representation 
of the address as a string: 
mysql> SELECT INET_NTOA(3520061480);
   ->  "209.207.224.40"

INET_ATON(expr) 
Given the dotted-quad representation of a network address as a string, returns an 
integer that represents the numeric value of the address. Addresses may be 4 or 8 byte 
addresses: 
mysql> SELECT INET_ATON("209.207.224.40");
   ->  3520061480


Doug



On Fri, 13 Jun 2003 10:19:32 +0100, Ronan Chilvers wrote:

>Here's how I did it when playing with this...
>
>Table definition:-
>
>CREATE TABLE ip_list (
>  ip_from double default NULL,
>  ip_to double default NULL,
>  country_code char(2) default NULL,
>  country_name varchar(100) default NULL,
>  KEY ip_from (ip_from,ip_to,country_code,country_name)
>) TYPE=MyISAM;
>
>Basic code to query it (takes a parameter 'ip' as GET paramter):-
>   /*
>   IP Lookup script
>   * prints a country code and name for an ip in the $_GET array
>   */
>
>   //Vars & Constants
>   define("HOST","myhost");
>   define("USER","myuser");
>   define("PASS","mypassword");
>   define("DB","ips");
>   define("IP",$_GET["ip"]);
>
>   // Functions
>   function dbconnect() {
>   if (($conn=mysql_pconnect(HOST,USER,PASS))===false) {
>   die("Couldn't connect to server");
>   }
>   if (!mysql_select_db(DB,$conn)) {
>   die("Couldn't select database");
>   }
>   return $conn;
>   }
>   function dbclose($conn) {
>   if (!mysql_close($conn)) {
>   die("Couldn't close database connection");
>   }
>   return true;
>   }
>   function dosql($SQL) {
>   if (($result=mysql_query($SQL))===false) {
>   die("Couldn't do sql : $SQL");
>   }
>   return $result;
>   }
>
>   //Core
>   $SQL = "SELECT COUNTRY_NAME AS cn, COUNTRY_CODE AS cc FROM ips.ip_list WHERE 
> IP_NUM BETWEEN ip_from AND ip_to";
>
>   $conn = dbconnect();
>
>   $ip = "127.0.0.1";
>
>   $QSQL = str_replace("IP_NUM",sprintf("%u",ip2long(IP)),$SQL);
>   
>   $result = dosql($QSQL);
>   $data = mysql_fetch_array($result);
>
>   echo "ip:".IP."";
>   echo "cn:".$data["cn"]."";
>   echo "cc:".$data["cc"];
>
>   dbclose($conn);
>?>
>
>HTH !!
>
>Ronan
>e: [EMAIL PROTECTED]
>t: 01903 739 997
>w: www.thelittledot.com
>
>The Little Dot is a partnership of
>Ronan Chilvers and Giles Webberley
>
>-- 
>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] Adding MySQL support to PHP - libmysqlclient.so version problem

2003-06-15 Thread Doug Thompson
This is in the archives, but it was faster to find it in my stack of saved stuff:


For those who installed RH 8.0 and went threw the same php/mysql woes you
just have to go to

http://rpmfind.net/linux/rpm2html/search.php?query=php-mysql

And install the 8.0.5 (psyche?) or 8.0.7 php-mysql rpm.


Doug

On Sun, 15 Jun 2003 23:38:31 -0400, Jack Orenstein wrote:

>I need MySQL support from PHP to support the HORDE/IMP webmail
>package.
>
>I just installed RedHat 9, and this included PHP 4.2.2-17. According
>to the PHP test.php page, MySQL support was configured:
>
> --with-mysql=shared,/usr
>
>However, later in the test.php page, there is no section on MySQL. 
>(Furthermore, the HORDE test.php says that PHP does not have
>MySQL support.)
>
>The MySQL version I'm using is 4.0.13-0. I realized that I needed
>php-mysql. Installing that binary rpm:
>
> libmysqlclient.so.10 is needed by php-mysql-4.2.2-17
>
>So I got MySQL-shared_4.0.13-0, matching the version number of my other
>MySQL RPMs. But that contains /usr/lib/libmysqlclient.so.12, not the .10
>version.
>
>How can I get mysql support in php? I'm hoping to avoid ripping out
>mysql and php and building everything from source.
>
>Jack Orenstein
>
>-- This is not a disclaimer --
>
>
>-- 
>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] Adding MySQL support to PHP - libmysqlclient.so version problem

2003-06-15 Thread Doug Thompson
So look a little farther down the list and try the RPM for RH9.0.


On Mon, 16 Jun 2003 00:05:19 -0400, Jack Orenstein wrote:

>Doug Thompson wrote:
>
>>This is in the archives, but it was faster to find it in my stack of saved stuff:
>>
>>
>>For those who installed RH 8.0 and went threw the same php/mysql woes you
>>just have to go to
>>
>>http://rpmfind.net/linux/rpm2html/search.php?query=php-mysql
>>
>>And install the 8.0.5 (psyche?) or 8.0.7 php-mysql rpm.
>>
>>
>This doesn't work for me. I have rh9 and the PHP any MySQL versions it 
>installed
>appear to be incompatible with the 8.0.7 php-mysql:
>
>error: Failed dependencies:
>php = 4.2.2-8.0.7 is needed by php-mysql-4.2.2-8.0.7
>libmysqlclient.so.10 is needed by php-mysql-4.2.2-8.0.7
>
>Jack Orenstein
>
>





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



Re: [PHP-DB] PHP Install conflicts w/ MySQL

2003-06-16 Thread Doug Thompson
Check that mysql is still the owner of its subdirectories. 

You might also look on the mysql list for other possibilities as this is a frequent 
topic.

Doug

On 17 Jun 2003 10:02:29 +0800, Ramil G. Sagum wrote:

>
>On Tue, 2003-06-17 at 03:08, Nathan wrote:
>
>> # ./bin/mysqld_safe &
>> Starting mysqld daemon with databases from /var/lib/mysql
>> 030616 12:04:24  mysqld ended
>> 
>> I'm running the command as root so I don't think it's a permission issue.  Does 
>> anyone know anything about the PHP install that would change the way MySQL is 
>> running?
>
>bothered to take a look at what the logs/error logs say?
>
>
>
>
>
>-- 
>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] connect to db with php?

2003-06-21 Thread Doug Thompson
1. The default user table sets up root with no password.  Leave out the password and 
it will probably connect OK.  You really need to fix the user table, but as long as 
the system isn't accessible from outside, you can get by.

2.  You don't need to use "host", in this case 127.0.0.1, when connecting from the 
same machine.  It doesn't hurt, but it may add confusion at some future point in your 
troubleshooting.

3.  All of this is really mysql specific and you would do better using that list, too.

Doug


On Sun, 22 Jun 2003 00:45:12 +1000, David wrote:

>Warning - beginner  :-)  I'm new at Linux, php and mysql, so please go slowly.
>
>I have a test database with a couple of tables, etc., that I can connect to 
>and run simple queries against, etc., all from the command line. I do most 
>things as root, probably because I didn't set it up right and haven't fixed 
>it.
>
>I'm trying to put together a simple php script to connect to the database and 
>learn about both at the same time. At the moment I have something like this:
>
>$conn = mysql_connect("127.0.0.1","root","password","databasename");
>if (!$conn) die ("Could not connect");
>blah blah
>?>
>
>which gives this result:
>Warning: Access denied for user: '[EMAIL PROTECTED]' (Using password: 
>YES) in /var/www/html/php/script1.php on line 9
> (line 9 is the $conn line, above)
>
>I've tried a few variations but I'm not sure where to go from here.
>Can anyone help out?
>thanks
>David
>
>-- 
>
>
>The arm folds in at the elbow, not out
>
>
>-- 
>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] Rand() Emulation

2003-06-24 Thread Doug Thompson
An incredible interpretation of


If called without the optional min, max arguments rand() returns a pseudo-random value 
between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for 
example, use rand (5, 15). 


Doug


On Tue, 24 Jun 2003 11:14:55 -0400, Gerard Samuel wrote:

>Doesn't really cut it when you do not know a min and max value, or want 
>to extract a random range of numbers.
>
>Becoming Digital wrote:
>
>>>Im trying to figure out a way to emulate mysql's RAND() function to be
>>>cross database compatible via php.
>>>Has anyone done anything similar to this???
>>>
>>>
>>
>>How about PHP's rand() function?
>>http://us2.php.net/manual/en/function.rand.php
>>
>>Edward Dudlik
>>Becoming Digital
>>www.becomingdigital.com
>>
>>Did I help you?  Want to show your thanks?
>>www.amazon.com/o/registry/EGDXEBBWTYUU 
>>
>
>
>-- 
>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] generating sequence without AUTO_INCREMENT

2003-06-26 Thread Doug Thompson
Maybe it's because I'm not fully awake yet that the problem seems less complex than it 
is.

What is wrong with using a seperate table for each year?

Doug

On Thu, 26 Jun 2003 08:43:17 +0200, anders thoresson wrote:

>Hi,
> I'm working on a web based article planning system for a news paper, based 
>on PHP and MySQL. One vital table in the setup will contain release date 
>and number for each issue. It's a simple table with just three columns:
> id, which is the primary key and AUTO_INCREMENT
> date, which is the release date for each issue
> issue_number
> I need help with a solution to automatically create the issue_number. The 
>conditions is as follow:
> 1. The paper is published every Monday to Friday, except for national 
>holidays, so issue_number isn't the same as the day number
> 2. The first issue each year should be number 1, and then the rest should 
>follow in sequence
> The first condition is taken care of manually, where one of the editors 
>will input a start date and an end date between which the newspaper will be 
>released Mondays to Fridays. That way I'll handle the national holidays, 
>for each year the editors have to enter a couple of date sequences to 
>"fence out" the holidays.
> But keeping track of each and every issue_number manually isn't practical. 
>I've looked at the MySQL manual, but all I find is LAST_INSERT_ID(). But 
>from what I've understood, that function is only useful when it's the same 
>value that is being updated, and this isn't the case in my problem.
> So I guess I'll have to write my own function. The solution I think of 
>right now is adding new issues in two steps: First adding the date for the 
>new issue to the table, then checking the issue_number for the date before, 
>and then adding the issue_number next in turn to the new issue, or, if the 
>year differs start over from 1 again.
> Is there a smarter way of doing this?
>
>-- 
>anders thoresson
>
>-- 
>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] MySQL full text search

2003-07-18 Thread Doug Thompson
Full text searches only work against fulltext indexes.

http://www.mysql.com/doc/en/Fulltext_Search.html

This isn't a PHP issue.

Doug


On Fri, 18 Jul 2003 09:42:17 +0200, Angelo Zanetti wrote:

>Hi
>
>I have a table which contains 3 fields (ID, Title, Abstract) the title and abstract 
>fields have been fulltext indexes like this:
>
>ALTER TABLE biblio ADD FULLTEXT (title,abstract);
>
>that worked fine, however my problem is whenever I want to do a select statement only 
>comparing 1 of the columns to inputted data ( in a Select statement):
>
>$result = mysql_query("SELECT * FROM Biblio WHERE MATCH (title) AGAINST 
>('$searchString')");
>
>It gives me this error: Can't find FULLTEXT index matching the column list. It 
>appears that i cant just compare a single fulltext indexed column if there are other 
>fulltext indexed columns. When I try it with both columns then it works but I just 
>want to compare 1 column. eg: 
>$result = mysql_query("SELECT * FROM Biblio WHERE MATCH (title, abstract) AGAINST 
>('$searchString')");
>
>So is there anyway that I can just compare 1 column with text entered? Do I have t 
>make some sort of temporary table to do this? All the examples I have found show the 
>select statement with 2 columns or if they use 1 coumn its because there is only 1 
>column in their table.
>
>Any help would be appreciated!
>
>TIA
>
>Angelo
>



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



Re: [PHP-DB] Regular Expressions? URGENT

2003-08-01 Thread Doug Thompson
Try one of these:

http://zez.org/article/articleprint/11

http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex_p.html

Doug

On Fri, 1 Aug 2003 11:34:16 -0400, Aaron Wolski wrote:

>Hi All,
> 
>Sorry for OT post but need some info.
> 
>Does anyone know a good tutorial that explains regular expressions in
>DUMMY terms?
> 
>I have a list of characters that I need to check to see if they are in a
>string. I tried creating an array of the characters but some of them are
>like  ' " and ` which seem to cause some problems.
> 
>Any good turotials for regular expressions?
> 
>Thanks a bunch!
> 
>Aaron
> 
>



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



Re: [PHP-DB] query works fine on console but not with PHP - why?

2003-08-03 Thread Doug Thompson
You have an error in your PHP code, just as the error says.
Including only the query, which you've already tested, isn't very helpful.

The error message is telling you that the result "link identifier" used in your fetch 
statement isn't the same as returned by the query statement OR there was an error 
returned by the query.

It's all in the manual.

Doug

On Sun, 3 Aug 2003 09:59:42 -0400, Aaron Wolski wrote:

>Hi guys,
> 
>I have the following query which returns FINE through the console but
>not in PHP
> 
> 
>select t.id, t.colour, t.colourID, t.price, t.type, g.thread_index,
>g.groupNameUrl FROM kcs_threads t LEFT JOIN kcs_threadgroups g ON t.id =
>g.thread_index WHERE g.groupNameUrl = '0-500'
> 
> 
>The error I am getting on the browser is:
> 
>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
>result resource in http://www.martekbiz.com/KCS/utils.inc on line 52
> 
> 
> 
>Anyone have an idea as to what it up?
> 
>Thanks!
> 
>Aaron
>



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



Re: [PHP-DB] % operator

2003-08-12 Thread Doug Thompson
One day I'll learn to wait until two cups of coffee before attempting to post replies. 
 On top of which, I have no idea where "0.8" came from.  8-/

Sorry for the confusion factor.

Doug


On Tue, 12 Aug 2003 10:47:21 +0100, Phil Driscoll wrote:

>On Tuesday 12 August 2003 10:39 am, Phil Driscoll wrote:
>> The modulus is the remainder after division hence 5 into 24 goes 3 times
>> with a remainder of 4,
>
>oops - 4 times with a remainder of 4 :(
>
>-- 
>Phil Driscoll
>
>
>-- 
>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] % operator

2003-08-14 Thread Doug Thompson
The "%" is called the Modulus operator.  It is very briefly explained in the PHP 
manual in table 11-2.

In your example, $mod = $a % $b  ==> $mod = 0.8

It is a very easy operator to use.

Doug


On Tue, 12 Aug 2003 11:04:39 +0200, Alain Barthélemy wrote:

>Hello,
>
>If you have
>
>$a = 24;
>$b = 5;
>
>and
>
>$c = $a/$b;
>
>===> $c = 4.8
>
>To retrieve the .8 (reste in french) I saw instruction:
>
>$a%$b
>
>Where can I find a manual for this '%' operator? Of course I already looked in
>all the Php manuals (operators, etc ...).
>
>Thanks,
>
>
>
>-- 
>Alain Barthélemy
>[EMAIL PROTECTED]
>http://bartydeux.be
>Linux User #315631
>
>
>-- 
>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] To slash or not to slash....

2003-09-03 Thread Doug Thompson
On Tue, 2 Sep 2003 16:45:28 +0100, Craig Cameron wrote:

>
>Ok simple problem I hope.
>
>
>Have the following code, used to store the location and a few details about meeting 
>minutes.
>
>
>   $connection = mssql_connect("server","user","password");
>   mssql_select_db("DocumentManager",$connection);
>   
>   $AlteredMinutesLocation = str_replace("\\","\",$MinutesLocation);
>
>   $SQL_STRING = "INSERT INTO tblMeetingMinutes 
> VALUES('$Date','$Type','$AlteredMinutesLocation','$Centre')"; 
>
>   $Result = mssql_query($SQL_STRING,$connection);
>   mssql_close($connection);
>
>
>
>Problem is the backslashes. When I collect the filepath ($Location) it puts \\ into 
>the db. However, when I change this it stops dead. Basically due to the escape 
>charateristics of the backslash. I can get around this with single quotes of course 
>but can't put these in the SQL_STRING as it falls down there then!
>
>Somebody must have come across this before, any help much appreciated.
>
>Cheers
>
>Craig
> 

Try using the built-in functions addslashes() and stripslashes().

Doug

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