[PHP-DB] Re: General PHP problem

2001-08-29 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Ali Nayeri) wrote:

> >> File php1.php
> print("Hi $name");
> 
> >>File test.htm
> 
> 
> Name:

Check phpinfo(): is the option "register_globals" turned on?  See
 for more info...

You may always want to do var_dump($HTTP_GET_VARS) and/or 
var_dump(get_defined_vars()) from php1.php.

-- 
CC

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




[PHP-DB] Re: query returned "Resource id #2"

2001-08-17 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Default) wrote:

> I'm using PHP 4 and mysql.  I'm trying to do just a simple query from a
> database table, but every time it returns the value, it returns
> "Resource id #2" and results like that.  Any ideas?  Thanks.

This is correct.  See the manual's info on each of the mysql_fetch_* 
functions. 

-- 
CC

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




[PHP-DB] Re: Off the point here!

2001-08-14 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Scott Fletcher) wrote:

> P.S.  the php.general & php.version4 newsgroup is now closed!

No they're not.  I just accessed both lists (via news server) without 
difficulty.  Maybe something's funky with your newsreader config?

-- 
CC

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




[PHP-DB] Re: ranking database searches

2001-08-08 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Michael Hall) wrote:

> This may be more trouble than I'm interested in, but I'm working on search
> functionality for a number of our MySQL database projects.
> 
> I'm looking for ways (or just ideas about ways) to set up a ranking system
> such that I could have exact matches at the top of the list, then multiple
> partial matches listed below that, and single partial matches below that,
> etc.

See the MySQL manual's section on FULLTEXT indexes.  It won't necessarily 
return results in exactly the order you describe, but will go you one 
better by ordering based on relevancy.

-- 
CC

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




[PHP-DB] Re: function ??

2001-07-28 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
wrote:

> are INSERT INTO statements forbiden inside a function??

Assuming that you're referring to a PHP function and not a function of the 
RDBMS, no it's not forbidden.  Show the relevant snip of code and any error 
messages being reported.  Most likely, you've got a typo or syntactical 
problem that's causing the insert to fail (ex. forgetting to bring a global 
var into the function's local scope, an extra curly brace, missing quote, 
etc.).

-- 
CC

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




[PHP-DB] Re: (preg_match ?

2001-07-27 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
wrote:

> $search = "TheName"
> $data = "TheName,TheAddress,ThePhone"
> 
> if (preg_match('"/\b'.$search.'\b/i"', $data)) 
> {
> echo "True";
> }
> else
> {
> echo "False";
> }
> I am trying to see if the search name matches exactly a name in the $data.

In that case, may I suggest an alternative method?

$arr=explode(",",lower($data));
if(in_array(lower($search),$arr)))
  ...

(If you want to use the preg_*: take out the double quotes in your regex, 
which do not appear to be delimiting the substrings within variable $data.)

-- 
CC

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




Re: [PHP-DB] remote database exchange

2001-07-16 Thread CC Zona

In article <001b01c10e52$0c08e060$3c41500c@zeospantera>,
 [EMAIL PROTECTED] (Ken Sommers) wrote:

> I ran
> mysql> show variables;
> to see if my host server has Oracle support,,

MySQL is a DBMS.  Oracle is a DBMS.  Different products from 
different vendors.  MySQL doesn't tell you if you have Oracle support.  

You can use the PHP function phpinfo() to see what options are compiled 
into your PHP install.  But the information show there can look pretty 
cryptic until you compare it against the manual to find out what each 
option means.

Simpler way: talk to your ISP.  Ask them all these questions.

> I don't see anything about Oracle  or any  other DBMS,,
> any way to tell without asking them?

Without asking who?  And why would you want to avoid asking them?  Your ISP 
should be a resource for you, not something to avoid.  And if it's the 
database owner you don't want to talk to, let me repeat: you need to be 
granted access to an account on the database.

-- 
CC

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




Re: [PHP-DB] remote database exchange

2001-07-16 Thread CC Zona

In article <012601c10e4a$6c7a2ec0$b943500c@zeospantera>,
 [EMAIL PROTECTED] (Ken Sommers) wrote:

> Suppose I Need to get Vendor prices from a very large remote (Oracle) price
> list .
> They probably don't have PHP installed.

If...

-you have PHP installed, 
-AND you have Oracle support compiled in to that install, 
-AND you have connection info (username/password/hostname) for an account 
on that Oracle system that has been granted access to vendor prices, 
-AND you know how to use PHP's Oracle functions, 
-AND you know how to query an Oracle database

...then you're set.  Whether they have PHP installed or not is irrelevant.

-- 
CC

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




[PHP-DB] Re: remote database exchange

2001-07-16 Thread CC Zona

In article <00d201c10e41$9fa2e340$b943500c@zeospantera>,
 [EMAIL PROTECTED] (Ken Sommers) wrote:

> Is it possible to exchange data on remote databases in PHP mysql?

PHP is a scripting language.

MySQL is a database management system (DBMS).

Two different things.

> Suppose I had a MUSIC database that you wanted your site visitors to be able
> to query,and it was OK with me because you had a MOVIE database that I
> wanted MY site visitors to be able to query,
> 
> Could we swing this?

(Already answered in the previous thread.)

> IF it exists,,where are all the tutorials and docs on it?

Any tutorial/book that explains how to make a "search engine" using PHP and 
MySQL can give you the overview.  The difference betweeen implementing that 
fuctionality via a remote connection vs. a local connection is trivial (a 
minor difference in the "host" setting for the database connection 
parameters).



-- 
CC

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




Re: [PHP-DB] Re: the body of the response

2001-07-16 Thread CC Zona

In article <00c801c10e3f$758ba8a0$b943500c@zeospantera>,
 [EMAIL PROTECTED] (Ken Sommers) wrote:

> are you saying that i can grab the output of your echo() statements in YOUR
> PHP script by Fopen()ing your URL

Yes, you can use it that way.

> IF so,, is this done much? 

It's done.  I can't quantify how often. But it's not considered usual or 
unorthodox, if that's what you're asking.

> or are there easier more stable less error-prone
> ways to access remote databases?

A) If you're trying to access a remote DBMS with fopen(), then the 
probability is very high that's your whole strategy is bass-ackwards.  So 
if that's what's behind these questions, your confusion is 
understandable--time to do a major re-think (and/or, as Ken has already 
suggested, spend more time with a PHP manual).

B) What makes you think fopen is unstable or error-prone?  I'd expect any 
connection to a remote server to have a higher risk of errors than a local 
connection, but you seem to believe that fopen() itself introduces new 
opportunities for errors above-and-beyond the remote connection itself.  
That I would not expect to be the case.

-- 
CC

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




Re: [PHP-DB] Re: the body of the response

2001-07-16 Thread CC Zona

In article <00c801c10e3f$758ba8a0$b943500c@zeospantera>,
 [EMAIL PROTECTED] (Ken Sommers) wrote:

> Suppose I had a MUSIC database that you wanted your site visitors to be able
> to query,and it was OK with me because you had a MOVIE database that i
> wanted MY site visitors to be able to query,
> would we set it up this way?

(Sorry, forgot to respond to this part before...)

Well, technically, you could...but generally-speaking, I wouldn't.  Not 
unless the database was very small, the queries were very simple, and there 
was good reason to avoid using a DBMS (ex. MySQL, PostgreSQL, Access, 
Oracle, etc.).

Also, if either of you considers the contents of your respective databases 
to be valuable (or sensitive), then you should consider that what you 
propose to do is put the entire contents of both databases up on the WWW 
for anyone to view/copy/download in toto.

-- 
CC

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




[PHP-DB] Re: the body of the response

2001-07-16 Thread CC Zona

In article <008101c10e0f$379207e0$c844500c@zeospantera>,
 [EMAIL PROTECTED] (Ken Sommers) wrote:

> PHP manual says:
> fopen
> fopen -- Opens file or URL
> Description
> int fopen (string filename, string mode [, int use_include_path])
> 
> If filename begins with "http://"; (not case sensitive), an HTTP 1.0
> connection is opened to the specified server, the page is requested using
> the HTTP GET method, and a file pointer is returned to the beginning of the
> body of the response.
> 
> can someone explain the clause:
> 
> "and a file pointer is returned to the beginning of the
> body of the response."
> 
> can someone explain and describe what this "body"  is?

Presumably that's what RFC 2616 refers to as the "message body", the part 
of the response that follows the headers.  Translated: what you get with 
fopen() is what you'd get by fetching the same URL with a browser and then 
viewing source.

BTW, fsockopen() can be used to get both headers ("Content-type", 
"Content-length", "Expires", "Location", etc.) and body 
("" or whatever).

-- 
CC

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




[PHP-DB] Re: problem with regular expression

2001-07-16 Thread CC Zona

In article <001601c10dc9$e4513780$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jennifer Arcino Demeterio) wrote:

> i have a script to identify if the input is a combination of letters and 
> numbers 
>  
> if (eregi("[a-zA-Z0-9][0-9]+[a-zA-Z][0-9a-zA-Z]",$fieldvalue)) 
> print "alphanumeric"
> } else {
> not an alphanumeric
> } 
> 
> my problem is, when the string ends with a number, for example hello123, it 
> says "not an alpanumeric" ... it works fine when the number is placed before 
> the letters or in between letters ... why is that? 


Your regex matches a pattern of:

-one alphanumeric
-followed by one or more digits
-followed by one letter
-followed by one alphanumeric

The string "hello123" is failing because it does not match the specified 
pattern.  (If "123hello" or "he123llo" really is passing as you describe, 
re-check your code because that should not be possible given the above 
regex.) 

If you want to know if the entire string consists (from beginning to end) 
of any combination of alphanumeric characters, try:

"^[[:alnum:]]+$"

-- 
CC

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




Re: [PHP-DB] cites/states data

2001-06-30 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jaskirat) wrote:

> I am creating a database driven php page for which I need to have a database 
> of
> US and Canadian states and cities in the back end.
> Is there some place on the web where I can get such data in the reusable 
> form and

You might try looking at census data.  It's public info, so free, and 
should have extensive lists of city info somewhere  (you may have to cobble 
together a complete list from various regional sub-lists, but then again 
maybe not...).

Another possible source: public GIS (geographic information system) 
databanks.  See 
, for instance.

There are also plenty of people willing to sell you such info... ;-)

-- 
CC

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




Re: [PHP-DB] mysql errors .... or php errors ????

2001-06-29 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Steve Brett) wrote:

> 'invalid index test assumed 'test' in test.php at line 13'  can't
> remember the exact syntax but that's the general idea.
> 
> if i quote the var when i reference it the error goes away. like
> $arow['test'] as opposed to $arow[test].
> so in general i quote them always BUT i tried to set up a php members board
> on my server yesterday using someones elses code (blazeboard) and got
> hundreds of these errors whihc leads me to believe it's either my php or
> mysql setup ...

Strictly speaking, these are not supposed to be the same thing:

$myarray[index]  //key uses the value of a constant named "index"
$myarray['index'] //key is the literal string "index"

It's a PHP warning that you're getting.  Because it's an informational 
error rather than fatal, the parser continues on as long as it can find an 
element with that same name (even though it's looking first for the 
constant).  If there's any danger of there being confusion between a 
constant and array element with the same name, then you need to correct the 
quoting.  If you set your error_reporting level lower (you probably have it 
at E_ALL now) the warning will no longer appear; but understand that it'll 
still be *occuring*--it's just that you just won't be reminded of that fact 
anymore.  So you still need to watch what you name those constants and 
keys!  (And in the future, get in the habit of quoting keys correctly so 
there's no room for confusion.)

-- 
CC

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




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

2001-06-28 Thread CC Zona

In article ,
 [EMAIL PROTECTED] (Brian Grayless) wrote:

> Is anyone familiar with this MySQL error?
> 
> "1062: Duplicate entry '127' for key 1"

You have a unique key (likely the primary key field).  There is already a 
record with value "127" in that field.

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

For options, see the MySQL docs on the "insert ignore" and "replace" 
keywords.

-- 
CC

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




Re: [PHP-DB] do table alias's work in PHP?

2001-05-16 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (cameron walker) wrote:

> It's hard to comprehend how this is a MySQL problem as my SQL commands work
> perfectly when entered at the command line. This fact is a pretty strong
> pointer to PHP being the culprit. Why empirical test would suggest otherwise?

A good empirical test is to echo/print the sql to the browser at the point 
where it is submitted to mysql_query().  Then copy/paste that back to the 
command line.

As long as the quoting isn't scewed up, PHP should not care what is in a 
query submitted to MySQL.  And since apparently PHP isn't throwing an error 
(you *are* checking the value of $php_errormsg, right?) it sounds like the 
only thing balking at this query is MySQL.

-- 
CC

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




Re: [PHP-DB] do table alias's work in PHP?

2001-05-16 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (cameron walker) wrote:

> Now I am using a shareware version which, perhaps, is buggy:
> 3.22.24-shareware-debug

Given that MySQL is currently well into the 3.23.* series, getting an 
upgrade would certainly be a good place to sart.  As for the "shareware" 
version, MySQL is now freeware on all platforms (on Win it used to be 
shareware)--and is quite stable on all but the most bleeding edge version 
releases.

Since your current problem is strictly a MySQL issue, may I suggest you 
take further questions about this topic to the excellent MySQL support list 
(see )?

-- 
CC

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




Re: [PHP-DB] 'the missing character'

2001-05-15 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jimmy Brake) wrote:

> Does anyone know of a function in php that will take a chunk of text and 
> seperate it into 'chunks' preferably returning it in an array?
> 
> The reason being is that I have some columns(oracle) that are set to 
> varchar2(4000) and I have text that is 4000+ AND :-) I cannot change it to 
> another format. 
> 
> I was unable to find a chunk maker so I built one.



I'm way tired so may not be reading your code closely enough, but it looks 
to me like you could do produce the same functionality like this:

$breakstring="***BREAK ME HERE!***"; //use whatever you want
$inputstring=wordwrap($inputstring, 3500 , $breakstring);
$outputarray=explode($breakstring,$inputstring);

-- 
CC

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




Re: [PHP-DB] Autoincrement Question

2001-05-10 Thread CC Zona

[quotes restored to bottom-posting order, for clarity]

> > > > If I have a database that has three records and I delete the entire
> > > > third record, when another record is then added will the auto increment
> > > > number be 3 or 4? Thanks.

> > > I will be 3 Jeff :)

> > Only if the auto increment values started at zero.  Otherwise, the number 
> > will be 4.

> That is true if you delete a row in between other records..if you delete 2 
> the fourth record added would be 4, not 2.  BUT..in the default installation 
> of mysql, if you delete the last record the auto increment will fill it's 
> place..trust me, I just tried it :)

What version of MySQL and table type are you getting that on?  I just tried 
it with a MyISAM table in 3.23.33 (insert, immediate delete, immediate 
insert), and the pk incremented as expected.  No re-use of values.

-- 
CC

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




Re: [PHP-DB] Autoincrement Question

2001-05-10 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Angie Tollerson") wrote:

> I will be 3 Jeff :)
> 
> 
> >>> "Jeff Oien" <[EMAIL PROTECTED]> 05/10/01 01:13PM >>>
> If I have a database that has three records and I delete the entire
> third record, when another record is then added will the auto increment
> number be 3 or 4? Thanks.

Only if the auto_increment values started at zero.  Otherwise, the number 
will be 4.

In answer to the question the poster seems to really be asking: 
auto_increment doesn't go back and re-use values from deleted rows.  What 
if you have data in other tables where a foreign key ties (undeleted) data 
in that table to the deleted row in the first table?  If the value was 
re-used, then the data in the second table would suddenly be establishing a 
bogus relationship to the new data in the first.

-- 
CC

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




Re: [PHP-DB] Mystery variable query?

2001-05-03 Thread CC Zona

In article <9cs791$mn3$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("martin helie") wrote:

> The problem, evidently, is that echoing the variable didn't show the html
> formatting (it was something like "" in an obvious way!

Look at it via source view next time.  Echoing the content wrapped in a 
 tag can also be handy.

> I wish there were a php debugger.

 There's a built-in for PHP3.  For 
PHP4, scroll down toward the bottom of the user annotations for a couple of 
options.

-- 
CC

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




Re: [PHP-DB] Mystery variable query?

2001-05-03 Thread CC Zona

In article <9crr9l$4c4$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("martin helie") wrote:

> assuming:
> 
> $var="1234";(type does not seem to matter)
> 
> this query returns no error, but no result either:
> 
> mysql("database","SELECT * FROM table WHERE id='$var'");

When you call mysql_query is it perhaps from inside a function, where 
variable $var has not been passed or made global?

(BTW, whenever you experience problems with a query, it's a good idea to 
echo the query string to the browser.  Often, this simple step makes it 
very clear where the problem lies.  Using mysql_error() and $php_errormsg 
on a query failure also can give you very useful information.)

-- 
CC

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




Re: [PHP-DB] Newbie question

2001-05-03 Thread CC Zona

In article <034101c0d3f3$0dd747e0$41041dd8@winbox>,
 [EMAIL PROTECTED] ("~BD~") wrote:

> at the end of my script, I run a set of closing and clean-up procedures..
> what I would like to be able to do is that when a user bails out of the
> script by closing the browser or leaving the site/page, detect that they've
> gone, and then go ahead and run my closing procedures.. is this possible?

http://php.net/manual/en/features.connection-handling.php
http://php.net/register-shutdown-function

-- 
CC

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




Re: [PHP-DB] database synchronizing

2001-05-01 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Benny K. Putera") wrote:

> I have 2 systems, local and internet.
> I want my Internet database is updated from local database.
> How can I make this through php script?

See the manual for your DBMS for info on terms like "replication", 
"backup", "mirroring", etc.

-- 
CC

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




Re: [PHP-DB] Error Msg: Wrong data type when performing "extract()"

2001-04-18 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Shahmat Dahlan") wrote:

> $result=mysql_query($sqlstmt);
> # print $result;
> $row=mysql_fetch_array($result)
> 
> extract($row);
> 
> If I do the above, I get the results below:
> 
> Warning: Wrong datatype in call to extract() in
> E:\winnt\temp\stock_in.php on line 39
> 
> I've went through the query, and it seems alright. It worked previously,
> now all of a sudden it doesn't work anymore.. Can anyone help me out.

Since apparently $row is not an array, I'd guess that mysql_fetch_array has 
nothing to fetch (i.e. no row was returned by the query).  Two things to 
get into the habit of doing:

1) check that the query was valid.  For example:
 $result=mysql_query($sqlstmt) or die("Query error: " . mysql_error());

2) check that the query returned 1 or more rows.  For example:
if(mysql_num_rows())
   {
   $row=mysql_fetch_array($result) or  die("Row fetching error: " . 
mysql_error()); //BTW, you were missing a semi-colon on this line
   ...
   }

-- 
CC

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




Re: [PHP-DB] PHP Forms

2001-04-17 Thread CC Zona

In article <001201c0c77c$a0262360$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Hector M Banda") wrote:

> I want to know how can I store all the forms in a place where users can run 
> them but are not available to the owner of the domain.

See the following for pages for info on using an include_path outside the 
web server document root.

http://php.net/configuration
http://php.net/security
http://php.net/include

> Or even  better, can PHP forms be encrypted?

http://zend.com/zend/products.php#encoder

(Way expensive for what you want to do.)

-- 
CC

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




Re: [PHP-DB] php with mysql - multiple tables

2001-04-15 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Shahmat Dahlan") wrote:

> $result=mysql_query($sqlstmt);
> 
> I know the $sqlstmt query does work. But if I do a mysql_fetch_array and
> assign it to a variable called $myrow,
> 
> while ($myrow=mysql_fetch_array($result)) {
>...
> }
> 
> how do I display the content array $myrow? When I do a,
> 
> printf("%s ", $myrow["equip.equip_type"]);
> 
> nothing is visible.

$result=mysql_query($sqlstmt) or die("Oops! MySQL error: " . 
mysql_error()); //"know" the query is valid

if(mysql_num_rows($result)) //"know" the query gave you something to fetch
   {
   while ($myrow=mysql_fetch_array($result))
  {
  ...
  }
   }

Where "..." is:

   printf("%s ", $myrow["equip_type"]); //no table name

or:

   extract($myrow);
   printf("%s ", $equip_type); //no table name and easier to read ;-)

-- 
CC

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




Re: [PHP-DB] Forms and PHP

2001-04-15 Thread CC Zona

In article <005201c0c61d$bd2bf620$97fe013d@piii500>,
 [EMAIL PROTECTED] ("CK Raju") wrote:

> I am unsuccessful in attempting to have the FORM work with POST method, while 
> there is a  with  alongwith other variables that I am 
> accepting directly from text fields.
>  
> Its something like this
> 
> 
>  / / I try to  populate from a table in MySQL (which works)--
> / / like this, which is in a loop--getting tableid and tablefield
>  $tablefield
> ?>
> 
> My problem starts here when I accept other variables before posting the form 
> contents.
> 
> eg: 
> 
> 
> 
> 
> 
>  
> 
> 
> 
> In my analyse.php, when I try to list out the various variables posted from 
> here, it doesn't show up. I even tried adding all the variables as input 
> type=hidden before submitting the form, but it still doesn't show up.
> 
> When there is no   section, the whole variables show up.
>  
> Where could I be wrong ? 

In your real code, are the quotation marks missing from your input, select, 
and option tags?  It may help to submit the script output (IOW, the HTML as 
the browser sees it) to an HTML validator.  Other than that, it might help 
to show what code you're using to check that the variables have been 
passed.  Perhaps the problem lies somewhere in the "receiving" script 
instead of the posting one...?

-- 
CC

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




Re: [PHP-DB] Really Dumb Question...

2001-04-11 Thread CC Zona

In article <00c701c0c2af$be478f40$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Darryl Friesen") wrote:

> > How do I create a table within my PHP? Heres what I currently have, but I
> > keep getting parse error on the "create" line...
> 
> Because create is not a valid PHP command.  You have to assign the create
> statement to a string, _then_ pass the string to mysql_query:
> 
> $sql = "create table $propTable (
>   ID int not null auto_increment primary key,
>   TourName tinytext,
>   TourTitle tinytext,
>   ViewTitle tinytext,
>   TourNum tinyint not null,
>   Applet tinyint not null,
>   Desc text,
>   TourPath text,
>   SmFile text,
>   LgFile text );
> ";
> 
> $result = mysql_query($sql);

And take out the semicolon immediately after the closing parenthesis in 
"LgFile text )".   :-)

-- 
CC

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




Re: [PHP-DB] Convertion Types

2001-04-05 Thread CC Zona

In article <9aj490$s1p$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Fernando Buitrago") wrote:

> Where is the functions referece of convertion types like: isinteger.

http://php.net/manual/en/function.is-integer.php
http://php.net/manual/en/ref.var.php

-- 
CC

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




Re: [PHP-DB] Delete all Data and keep the Table

2001-04-02 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Naga Sean) wrote:

> How to delete all the data in database, without delete the table.

Do you want to delete every *table* in the *database*, or delete every 
*row* in the *table*? Assuming the latter, "delete from database_name".

-- 
CC

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




Re: [PHP-DB] Search results

2001-04-01 Thread CC Zona

In article <001301c0bafa$34d15be0$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("David Drummond") wrote:

> Can anyone tell me what is the best way to implement displaying multiple 
> search results using next and previous buttons to cycle through all the 
> results.  I see this method done on a lot of sites but don't know how to do 
> it in PHP.

"Limit" is how it's commonly done (though what's "best" really depends on 
what you're doing).  In mysql, it would be something like:

mysql_query("select foo from bar limit 5,10",$connect) //show ten records 
from result set, starting with the sixth 

I believe phpbuilder.com has a tutorial on this.  If not them, then you 
shouldn't have much trouble finding examples on one of the other PHP 
tutorial sites.

-- 
CC

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




Re: [PHP-DB] MySQL max_connections

2001-03-30 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Lee Stretton) wrote:

> Got a bit of a problem with the number of users accessing a website
> driven by a MySQL database. I want to increase the number of allowed
> connections to the database,  I have found the variable to change
> (max_connections) but have not been able to find out how, or where to
> change it. So if anyone can let me know it would be very helpful.

  See in particular the 
section on "set-variable".

-- 
CC

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




Re: [PHP-DB] Copy data from one mysql table to another?

2001-03-28 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Bob Stone) wrote:

> I cannot find any documentation on how to copy the
> data from one mysql table to another, i.e. table1,
> columnx to table2, columnx.

See the mysql documentation of the "insert into" syntax for how to use a 
trailing "select" statement to get the values to be inserted.  In a single 
statement you can select the data from one table and insert it into 
another.  Example: "insert into table2 (p_key,data) select p_key,data from 
table1 where p_key >100 and data !='garbage'"

(This also works for "replace into" and "create table" statements, BTW.  
Nifty, eh? )

-- 
CC

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




Re: [PHP-DB] Checking for empty string - long

2001-03-27 Thread CC Zona

In article <99qq47$jvn$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Martin Skjoldebrand) wrote:

> How do I check for an empty string in PHP/MySQL.

http://www.php.net/empty/
http://www.php.net/is_null/

-- 
CC

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




Re: [PHP-DB] How do you define table row indexes?

2001-03-27 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Anyangwe, Tanwani") wrote:

> $result = mysql_query("SELECT * FROM motor_vehicle",$db);
> $strSep = ' | ';
> while ($myrow = mysql_fetch_array($result))
> {
> echo $myrow['id'].$strSep;
> }
> 
> Gives me the following error:
> 
> Warning: Undefined index: id in C:\PHP\Test_Scripts\testdb2.php on line 16

1) It's not considered a good habit to use "select *" in scripts.  When you 
later modify the table defs, your scripts will be blown.  Even if you never 
add/drop/change a column, it's still messy since whenever you're working on 
the code you have to remember--accurately--all of the columns and exactly 
(case_sensitive_ what they are named.  Yuck.  Much cleaner to include the 
column names in your query now.  "Select id from motor_vehicle"--then you 
know for sure you're working with a column of that name.

2) mysql_fetch_array doesn't fetch NULLs.  If the value of column 'id' in a 
given row is NULL, then $myrow['id'] will be undefined for that row. See 
.

-- 
CC

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




Re: [PHP-DB] Getting info from remote host

2001-03-26 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] wrote:

> My idea was to make the http request and load it into an array, to be
> output in a PHP page.



-- 
CC

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




Re: [PHP-DB] newbie help

2001-03-26 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Matt Coyne) wrote:

> now does anyone know about getting ages from dates of birth (previous post
> of mine) and also searching by age group when you only have dates of birth
> in the table!!

See the MySQL manual's chapter on date/time functions for many options.  
Personally, I'm a big fan of date_add() and date_sub() since they allow for 
using relatively "natural language" intervals like "interval 1 day" or 
"interval 3 year" when doing the calcuations.  Easier to read ==> easier to 
debug (IMO).

-- 
CC

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




Re: [PHP-DB] database search

2001-03-26 Thread CC Zona

In article <99mtsa$85b$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Mark Collins") wrote:

> Hope you can help, I have put a basic database together which add, deletes,
> updates and edits records but I am not sure where to start with searching
> the data base. I have already got it working a bit using ereg and a while
> loop, but it is case sensitive and wont find a match in the middle of a
> string (or at least I dont think it will). Does anyone know of a better way
> to do this?

eregi() is for case-insensitive matching

The preg_* functions allow switching back and forth between case-sensitive 
and case-insensitive subpattern matching within a single pattern.

-- 
CC

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




Re: [PHP-DB] reading a URL...

2001-03-26 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] wrote:

> Is it Possible, in PHP to read a URL?
> 
> What I am trying to do is this...
> I have many news stories in a database, and a single static news page, that
> calls the story, and the corresponding headline.
> I have looked about on-line, and seen a common URL,...
> 
> http://www.arandomsite.com/news_story.php?id=123
> 
> I have adopted this method, and it only displays the top most story in my
> database, no matter what news ID I use.
> 
> Can I get the ID number from the URL?, and then pass that to the SQL 
> statement?

Yes to both, and quite easily.  All the variables passed in a GET request 
(which is what the url is) will automatically be made available in the 
$HTTP_GET_VARS associative array.  So variable "id" is at 
$HTTP_GET_VARS['id'].  In addition, if the configuration setting 
"register_globals" is turned on, the variable will also be accessible 
simply as $id.

So in the script news_story.php, you could write a query string like, for 
example:

"SELECT article_text from story_table where id=$id"

or

"SELECT article_text from story_table where id=" .
$HTTP_GET_VARS['id']

See 

-- 
CC

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




Re: [PHP-DB] error and general problems

2001-03-26 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Liz Bander) wrote:

> I am getting a parse error for the return line every time I try and view 
> the page.   Can anyone tell me why?  The code is below.
> 
> $results = "select req, source, number from orders where req=" . 
> $GLOBALS["req"] . ", source=" . $GLOBALS["source"] . ",
>   number=" .$GLOBALS["req"] . "";
> 
> if (mysql_fetch_row($results) != 0) {
>  return "This has already been added.";

Is this inside a function?  'Cuz AFAIK a "return" would only make sense 
inside a function.  

FWIW, the comparison of the fetched row to zero strikes me as a bit 
unusual.  Are you just checking whether there was no rows were returned by 
the query?  If so, I suspect that checking mysql_num_rows() would be more 
efficient.

> Also (since this is part of the problem, I'm sure) how do I take the 
> $GLOBALS values and set them equal to the req and source values in the 
> select statement?  Is this syntax correct?

Depends.  MySQL needs string values quoted too, so if for example all of 
those variables are strings you'd do something like:

$results = "select req, source, number from orders where req='" . 
$GLOBALS["req"] . "', source='" . $GLOBALS["source"] . ", number='" . 
$GLOBALS["req"] . "'";

-- 
CC

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




Re: [PHP-DB] What's wrong with this code?

2001-03-26 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Emir Musabasic) wrote:

> I have user/password/host variables inside a config
> file but for some reason when I include this into a
> php page when I test it, I get:
> 
> Fatal error: Cannot redeclare db_connect() in
> /www/affiliate/include/functions.inc on line 7.
> 
> Am I missing something because everything looks good
> to me.

Try using include_once() instead of include().  You're probably 
inadvertantly re-including the file.  In general, except where you're 
deliberately making multiple includes of the same file, it's a good idea to 
get in the habit of using include_once() or require_once() to save yourself 
from surprises like this.

-- 
CC

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




Re: [PHP-DB] Error Control

2001-03-26 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Jason Bell") wrote:

> Hello! I'm writing a script that validates a form It creates users in a
> mysql table, where there are 2 unique columns 'username' and 'email'.
> 
> I'm putting mysql_error() into a variable, but I don't want the end user to
> see that particular message... is there a way to look at just the key that
> has been duplicated, and create a custom error message for user display?
> 
> for example, when I duplicate a username, 'jbell', I get this from
> mysql_error() : "Duplicate entry 'jbell' for key 2"
> 
> I want to be able to see that the error is from key 2, and react
> accordingly

>From a MySQL perspective, you could adjust the query so no error is 
generated.  See the syntax for "INSERT IGNORE" or "REPLACE" for instance.

>From a PHP perspective, there are functions such as set_error_handler() or 
register_shutdown_function() to deal with such issues.





-- 
CC

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




Re: [PHP-DB] newbie help

2001-03-25 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Matt Coyne) wrote:

> I have been trying to detect if the variable holds any value and then
> building a query by concatenating like this:

if(!empty($foo))
   {
   ...
   }

> $result=@mysql_query($concatsql, $connection) or die ("bugger...!");
> 
> This just dies on mysql_query.

$result=@mysql_query($concatsql, $connection) or die (mysql_error() . " 
from query \n$concatsql"); //show as much relevant info as possible

When building complex queries like this, it's really easy to miss a missing 
quote or extra comma, etc.  Displaying the query string usually makes it 
quite obvious where the problem lies (especially when coupled with a MySQL 
error message, since MySQL is pretty good about pointing out the spot where 
the syntax fails).

-- 
CC

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




Re: [PHP-DB] Date

2001-03-25 Thread CC Zona

In article <002f01c0b52b$d4778e00$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("[EMAIL PROTECTED]") wrote:

> I save the date in my MySQL db as 2001-03-25.
> 
> But in my PHP script i want do see it like 25-03-2001.

Do it in the MySQL select.  Assuming date_field is of field type 'date':

select date_format(date_field,"%d-%m-%y") as date_formatted from mytable;

(See the MySQL manual's section on date/time functions for more ideas)

-- 
CC

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




Re: [PHP-DB] SQL Select?

2001-03-24 Thread CC Zona

In article <99jh2n$gr1$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Grant") wrote:

> Is there any way of using a string in an SQL query instead of using the
> table name. Something along the lines of
> 
> $result=mysql_query("SELECT * FROM $tablename",$db);
> 
> this doesnt work it come up with a parse error

"SELECT * FROM $tablename" should be sufficient to permit PHP variable 
expansion.  MySQL will also require a string value to be quoted, so if 
$tablename is a string, change the query to "SELECT * FROM '$tablename'".

AFAIK, the missing inner quotes would not cause a PHP parse error, only a 
MySQL error. So you may want to look for something else in your code that 
could be causing the parse error.

-- 
CC

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




Re: [PHP-DB] read fils

2001-03-24 Thread CC Zona

In article <004101c0b44b$b8e90640$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("[EMAIL PROTECTED]") wrote:

> I just want to read a txt file and let the output in php file.
> 
> Can someone help me?



For more sophisticated alternatives, see 
.

-- 
CC

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




Re: [PHP-DB] Procedure to Include

2001-03-22 Thread CC Zona

In article <011201c0b29b$7b6d9cb0$0101a8c0@server>,
 [EMAIL PROTECTED] ("Pankaj Ahuja") wrote:

> Can anybody tell me the procedure and/or code necessary to include another
> document into a .php document

http://www.php.net/include
http://www.php.net/manual

-- 
CC

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




Re: [PHP-DB] More on strings

2001-03-20 Thread CC Zona

In article <007901c0b153$ae861a80$660083ca@oemcomputer>,
 [EMAIL PROTECTED] ("Mick Lloyd") wrote:

> Thanks for the reply. I tried the variable route but again failed. I think
> from your suggested line of code you may have misunderstood the problem. The
> LIKE option works fine without having to put it into a variable.
> 
> $sql = "select Primaryid from primarycodes where Code =
> '$row[Primaryexpertise]'";
> print $sql."\n";
> 
> \\Prints: select Primaryid from primarycodes where Code = 'Biology' \\which
> seems OK
> 
> $resultp = mysql_query($sql) or die ("Failed"); \\This seems to work
> $pcodeid = mysql_fetch_array($resultp) or die("No pcodeid");
> 
> \\Prints: No pcodeid \\ie failed

mysql_query() returns true as long as the query syntax appears valid; it 
does not indicate whether the query actually found rows or not.  So just 
because the code didn't die on the mysql_query() line, you cannot assume 
the query "works" as intended.  The fact that the mysql_fetch_array() line 
dies would suggest that the query above likely is failing for some reason.  
One thing you can do is check mysql_num_rows() first to determine whether 
the query found any records.  Another thing you can do is echo $sql, then 
copy/paste that query at the command line to determine whether it's the SQL 
itself that's the problem or the PHP code.  Finally, instead of displaying 
your own ambiguous error messages on die(), let MySQL & PHP report to you 
what they know about the problem.  Example:

$resultp = mysql_query($sql) or die('Query failed.  MySQL says: ' . 
mysql_error() . '. PHP says: ' . $errormsg . '.');

-- 
CC

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




Re: [PHP-DB] Re: [PHP] how do i get a variable type? - not that simple

2001-03-18 Thread CC Zona

You could use ereg/preg to determine whether it:

a) consists of nothing but digits from beginning to end, example: ^[0-9]+$
b) consists of nothing but digits separated by a single decimal, example: 
^[0-9]+[.][0-9]+$
c) doesn't match the first two conditions, and therefore assume it is a 
string.



In article <9938lh$e5k$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("phpman") wrote:

> i can't though, the variable and its value comes out of a string .. like
> this..
> 
> $var_string =
> "var1=this_is_a_value|var2=4.5|var3=another_value|var4=3.1415";
> 
> then i extract the pairs of vars and vals, then I need to determine if val
> is string or integer.
> 
> 
> - Original Message -
> From: "Michael Geier" <[EMAIL PROTECTED]>
> To: "phpman" <[EMAIL PROTECTED]>
> Sent: Sunday, March 18, 2001 2:37 PM
> Subject: RE: [PHP] how do i get a variable type? - not that simple
> 
> 
> > anything wrapped in quotes is a string...
> >
> > try:
> >
> > $a=3;
> > echo(gettype($a));
> >
> > -Original Message-
> > From: phpman [mailto:[EMAIL PROTECTED]]
> > Sent: Sunday, March 18, 2001 12:44 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] how do i get a variable type? - not that simple
> >
> >
> > No guys. that doesn't work. Take this code for example...
> >
> > $a="3";
> > echo(gettype($a));
> >
> > this returns  string
> > i need to find it as an integer or real or float for the sql. which by the
> > way is MySQL.
> >
> > thank you for responding, but I already know that gettype and all the
> other
> > is_*  don't work for this.

-- 
CC

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




Re: [PHP-DB] MYSQL Trouble with the IN operator

2001-03-18 Thread CC Zona

In article <9937to$794$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Jen") wrote:

> SELECT CONCAT(c.l_name, ", ", c.f_name) name
> FROM contractor c
> WHERE c.contractor_id NOT IN
> (select c.contractor_id
> FROM contractor c, task_assign t
> WHERE c.contractor_id = t.contractor_id
> AND t.task_id=11);
> 
> It throws an error with the NOT IN line.  I can replace the NOT IN with NOT
> IN(3) giving it a value, and that works.  I was under the impression that
> you could put a query in the Not in.

That's a subquery.  MySQL doesn't support subqueries (yet).  See the manual.

-- 
CC

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




Re: [PHP-DB] if () and () - newbie Q

2001-03-18 Thread CC Zona

In article <000f01c0af50$e5092480$6609ee8d@pmg>,
 [EMAIL PROTECTED] ("Michael Gerholdt") wrote:

> what about something like 'isNull' ? I don't see any documentation in the
> PHP online manual nor is 'null' even mentioned in the index of my Core PHP
> book.

You must not have looked very hard.  Next time, check the function list or 
use the manual's search feature, 'cuz it was right there: 


-- 
CC

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




Re: [PHP-DB] Strings

2001-03-18 Thread CC Zona

In article <003801c0afa2$2d5853e0$890083ca@oemcomputer>,
 [EMAIL PROTECTED] ("Mick Lloyd") wrote:

> Can anyone advise on how to surround a string variable in a query. I select
> a string code from a column using:
> 
> $result = mysql_query("SELECT * FROM $TA WHERE Profileid = '$profileid'");
> $row = mysql_fetch_array($result);
> 
> I then want to extract from a second table an id  that relates to the code
> from the first query. I've tried various combinations of:
> 
> $result = mysql_query("select Primaryid from primarycodes where Code =
> '$row[Primaryexpertise]'")

Associate array indexes should be quoted:

$row[Primaryexpertise] //not like this
$row['Primaryexpertise'] //like this
$row["Primaryexpertise"] //or like this

Also, even though simple variable references are expanded within 
double-quotes (ex. "where Profileid = '$profileid'"), the PHP parser seems 
to be less certain about how to deal with array indexes: is the square 
bracket intedned as plain text, as a special character (such as in a 
regular expression) or is it actually an array index?  I find that dropping 
out of quotes whenever referencing array indexes eliminates a lot of parse 
errors.  For example:

"select Primaryid from primarycodes where Code = '" . 
$row['Primaryexpertise'] . "'"

Another option is to use extract() so that the array element can be treated 
as a simple string variable:

extract($row);
$result = mysql_query("select Primaryid from primarycodes where Code =
'$Primaryexpertise'")

> String manipulation has me baffled most of the time!

Re-read the manual's chapters on strings and arrays.  Also check out the 
Zend site.  There are some interesting articles and tutorials over there 
that address issues not yet adequately covered in the manual.

-- 
CC

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




Re: [PHP-DB] If`s in MySQL.... Having some trouble here...

2001-03-16 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Trond Erling Hundal") wrote:

> I want to query two tables in my db. One containing a list of numbers
> ranging from 1 - 10200, the other table is storing information that is
> relative to some of the numbers:
> 
> Eks:
> Table1.record1:  number=1
> 
> Table2.record1:  number=1 name=John
> 
> Now I want to query these to tables to show a table that has one column with
> the numbers, and if there is a name stored in the other table for this
> number, I want to display this.

Try:

select table1.number as num, name FROM table1
left join table2 using (number)

-- 
CC

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




Re: [PHP-DB] If expressions in selects....

2001-03-15 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Trond E. Hundal") wrote:

> Is it possible to run sql expressions in an if expression???
> Eks: IF(table1.id > 12, table1.id, 'Not')

Do you mean something like "select if(table1.id > 12, table1.id, 'Not') 
from foo where somefield='bar'"?  Yes, it's possible.  See the mysql.com 
manual for details.

-- 
CC

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




Re: [PHP-DB] Storing character returns

2001-03-12 Thread CC Zona

In article <98jdeu$46r$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Dan Eskildsen") wrote:

> I store newspaper articles into a MySQL database.  The text that I insert
> (via phpwizard.net) contains a little formatting: line returns to separate
> paragraph, but when I suck the data out again  to display it all the
> character returns vanish.
> 
> Any ideas?

nl2br()

-- 
CC

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




Re: [PHP-DB] upperCase

2001-03-11 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Hoo Kok Mun) wrote:

> This is what I did and it did not work.
> $userfield = upper('$userfield');
> echo "User Field - $userfield";
> 
> Errors (tried both ucase and upper)
> Call to undefined function: upper()
> Call to undefined function: ucase()

Yep, because you're using the wrong name(s) for the function known as 
"strtoupper" (confusing PHP functions with those of some other language, 
perhaps?).

BTW, a quick search of the manual or skim through the list of string 
functions would have revealed the problem--and solution--immediately.

-- 
CC

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




Re: [PHP-DB] php-mySQL and an SQL query

2001-03-08 Thread CC Zona

And even without the subquery, the "like" keyword expects a wildcard 
character or two, for example:

LIKE '$month%' "

> mysql doesn't support sub-queries unfortunately =(
> 
> 
> 
> 
> At 10:22 PM 3/8/01 -0500, Michael Gerholdt wrote:
> >Hi, folks,
> >
> >Can someone insight me regarding this?
> >
> >I have a datetime field in mySQL (-mm-dd hh:mm:ss) called event_time
> >
> >I want to pull records hitting against this field with the idea:
> >
> >where the abbreviated month from this field LIKE '$month'
> >
> >and here's the SQL string I've been playing with. It works when I comment
> >out the line that tries to do the above with a subquery.
> >
> >$strSQL = "SELECT DATE_FORMAT(event_time, '%M %e %Y, %l:%i %p'), bandname,
> >image ";
> >$strSQL .= "FROM doings, styles ";
> >$strSQL .= "WHERE style = musicstyle ";
> >$strSQL .= "AND bandname LIKE '$artist' ";
> >$strSQL .= "AND style LIKE '$style' ";
> >$strSQL .= "AND (SELECT DATE_FORMAT(event_time, '%b') FROM doings) LIKE
> >;
> >$strSQL .= "ORDER BY event_time";
> >echo "$strSQL";
> >
> >$month will be carrying the three-character short version of the alpha month
> >name.

-- 
CC

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




Re: [PHP-DB] Search engines & database driven sites

2001-02-27 Thread CC Zona

(re-ordered to bottom-posting, for clarity)

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Scott Bernard") wrote:


> I recently converted my sites from hardwired HTML to a PHP/MySQL
> combination - with dynamic 'newsy' info held in a database, tailored for
> each visitor. Unfortunately the 'hit rate' from search engines has gone
> virtually to zero as Altavista, Hotbot etc. removed me from their indexes -
> they don't index .php files as far as I can see, and also don't follow links
> on php pages (I imagine it's the same for ASP, ColdFusion etc.). In contrast
> Google and All The Web have no problems with the .php extension (and even
> index my .pdf files!).


> What you can do is create an html page blank, with meta-tags for the search
> engines, but including the meta:
> 
> 
> at the first line. This is going to redirect to the indicated php page.
> 
> I think its a solution, for the search enginges as for the users, because
> the will not see anything.
> 

Some search engines don't care, but not all view this in the same way.  
According to Search Engine Watch 
, AltaVista and 
Go.com are among those who treat a meta refresh as spam.  And since 
AltaVista is one of those you're trying to improve ranking with...

-- 
CC

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




Re: [PHP-DB] array awry

2001-02-27 Thread CC Zona

In article <061201c0a063$08eab5a0$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Keith Spiller") wrote:

> This associative array embedded within a function and declared as a global at 
> the start of the function, is meant to be a multidimensional array, but with 
> every loop of the while ($myrow = mysql fetch row($result)) statement, it's 
> previous values are replaced by the new ones.  Any ideas on how I can fix 
> this?
> 
>   If ($Selection == "3")
>   {
>   $tabledata[catid]= $myrow[0];
>   $tabledata[category] = "$myrow[1]";
>   $tabledata[under]= $myrow[2];
>   $tabledata[corder]   = $myrow[3];
>   $tabledata[active]   = $myrow[4];
>   }


So what you're saying is that want indexes 'catid', 'category', etc. to 
have a distinct value for each row pulled from the database?  Then you need 
to add another dimension to that array.

-- 
CC

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




Re: [PHP-DB] Data input

2001-02-21 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Matthew Cothier") wrote:

> How can they input the data into the database as they typ eit in without 
> them having to add html <.br.> tags?

nl2br()

-- 
CC

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




Re: [PHP-DB] assoc arrays

2001-02-20 Thread CC Zona

In article <[EMAIL PROTECTED]>, 
[EMAIL PROTECTED] ("Free Beachler") wrote:

> the form variables from an http post are stored in:
> 
> http_post_vars[] - associative array containing form variables..
> 
> what about url parameters, such as::
> http://www.mysite.com?param1=12
> 
> is there a corresponding array for them, or do they
> go in the post_vars array?

$HTTP_GET_VARS[]

-- 
CC

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




Re: [PHP-DB] apostrophe

2001-02-19 Thread CC Zona

In article <01cd01c09b0d$7f247630$0101a8c0@server>, [EMAIL PROTECTED] 
("Pankaj Ahuja") wrote:

> Is it possible to insert apostrophe into a Mysql database ?? I have a
> varchar type column and want to insert " manufacturer's" into it. How can I
> do this ??

Escape it with a slash: " manufacturer\'s". Or have PHP do it for you: 
addslashes(" manufacturer's").

-- 
CC

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




Re: [PHP-DB] Hide Files

2001-02-19 Thread CC Zona

In article <000c01c09ac2$7ed27ab0$0100a8c0@fusion>, [EMAIL PROTECTED] 
("Fusion") wrote:

> while ($file name = readdir($dir)) {
> 
> if (($file name != ".")
>  && ($file name != "..") 
>  && ($file name !="*.php")
>  && ($file name !="main.gif")
> 
> )  
> {
> 
> how come that still displays all the *.php files? 

Are you trying to use '*' as a wildcard character?  Because right now, it's 
only looking to exclude a file with the exact, literal name '*.php'--not 
files like 'anything.php'.  Check out the regular expression functions, 
either the ereg_* family or preg_*, to do pattern matching.

-- 
CC

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




Re: [PHP-DB] Using include() to specify mysql_connection??

2001-02-16 Thread CC Zona

In article <96klap$c8p$[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
("Boclair") wrote:

> Is it possible to place the mysql connect and mysql select db functions in 
> an include file and to open the connection and use the database in a PHP 
> file using include(); ?
> 
> All that happens when I attempt it is that the text of the include file is 
> dumped, the connection to the mysql server is not opened and the variables 
> are not created.

To be parsed as PHP code, the contents of the included file also need to be 
in PHP mode .

-- 
CC

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




Re: [PHP-DB] logs

2001-02-04 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
(Marc Bragg) wrote:

> Does php log its activity anywere? especially for debugging purposes?
> Some of my scripts don't show any browser window areas, but also don't
> show any results int he browser, i.e.,  a blank screen, and yet aren't
> working. thanx.

You can change PHP's logging behavior in the php.ini file.  As for results 
not showing up in the browser, try doing View Source.  Remember that there 
can be a difference between "stuff sent to browser" and 
"stuff interpreted as HTML and therefore presented in the standard browser 
window"...

-- 
CC

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




Re: [PHP-DB] Listbox Data Entery

2001-02-02 Thread CC Zona

In article <95erfd$neg$[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
("iGuru") wrote:

> I have a little problem. I have a listbox (multiline combo box) on my web
> page. When I sellect multiple items from the list box and submit the for to
> enter the values of the listbox items in the database, then only last
> selected item of the listbox is entered in the MySQL database.

Instead of name="var_name", you want name="var_name[]".  The square 
brackets define the variable as an array instead of a string.

-- 
CC

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




Re: [PHP-DB] sql: LIKE

2001-01-11 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote:

> "SELECT bar FROM foo WHERE bar LIKE '%foo%'" should return something like
> the order
> 
> bar
> ---
> 'foo' (exact match)
> 'the foo is a foo is a foo' (3 matches)
> 'have you seen the foo?' (1 match)

What DBMS?  In recent versions of MySQL "fulltext" indexing was added; it 
does approximately what you describe.

-- 
CC

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