php-general Digest 8 Nov 2003 15:18:27 -0000 Issue 2403
Topics (messages 168932 through 168957):
Re: *SOLVED* [PHP] problem transferring a variable using POST
168932 by: Erik Osterman
Re: Adding a log file
168933 by: Erik Osterman
168935 by: John W. Holmes
Re: advise on new class of mine
168934 by: Erik Osterman
Re: Array --> If
168936 by: Erik Osterman
BRU Help
168937 by: Nitin
Re: Japanese character validation
168938 by: - Edwin -
168939 by: - Edwin -
168943 by: Eugene Lee
168948 by: Dave G
168952 by: - Edwin -
168954 by: - Edwin -
Re: fopen url
168940 by: Jason Wong
Date to string (with mask)
168941 by: Christian Ista
168953 by: Filip de Waard
168955 by: Filip de Waard
How Can I read this Array
168942 by: dr. zoidberg
168946 by: Burhan Khalid
phpmysql(which array function?)
168944 by: Joffrey Leevy
168945 by: Joffrey Leevy
168947 by: Burhan Khalid
168949 by: Marek Kilimajer
Beveled text
168950 by: Siddhartha Lahiri
168951 by: Nathan Taylor
Problem Understanding Code in 2nd edition Welling/Thomson PHP?MySQL Web Development
Book
168956 by: Stephen Tiano
DW Php update form where one field is menu from another table
168957 by: Robb Kerr
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
I recommend using this function when inserting data directly from a form
post into the database.
This function automatically escapes the values you input.
function Query()
{
$values = func_get_args ();
$statement = array_shift($values);
if( sizeof($values) != substr_count($statement, '?') )
warn("Statement parts don't match number of values", true);
$query =
preg_replace("/(\?)/e","\"'\"[EMAIL PROTECTED](@array_shift(\$values)).\
"'\"", $statement);
# print "[$query]";
return mysql_query($query);
}
Usage:
$result = Query("INSERT INTO foo (var1, var2) VALUES( ?, ? )", $_POST[var1],
$_POST[var2]);
Regards,
Erik Osterman
http://osterman.com/
-----Original Message-----
From: Davy Campano [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 09, 2003 9:14 AM
To: [EMAIL PROTECTED]
Subject: [PHP] *SOLVED* [PHP] problem transferring a variable using POST
It worked. Thank you very much everyone for the quick responses. I am
just learning PHP and mySQL so I appreciate the suggestions. I only
wish that I would have written this email an hour ago!
-----Original Message-----
From: Chris W. Parker [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 09, 2003 12:08 PM
To: Davy Campano; [EMAIL PROTECTED]
Subject: RE: [PHP] problem transferring a variable using POST
Davy Campano <mailto:[EMAIL PROTECTED]>
on Thursday, October 09, 2003 8:57 AM said:
> This statement works:
> $sql = 'UPDATE wo SET status = 1 WHERE ticket = 1'
>
> This statement does not:
> $sql = 'UPDATE wo SET status = 1 WHERE ticket =
> $HTTP_POST_VARS[ticketed]'
>
> Any suggestions...
>
> If I do "echo "$HTTP_POST_VARS[ticketed]";
> It returns a 1
First of all you should be using $_POST and not $HTTP_POST_VARS (that is
of course if your version of php supports it).
Secondly, it's not working because (1) you are wrapping the sql
statement in single quotes which does not evaluate variables, it's a
string literal. You should change all those ' to ", and (2) arrays are
treated differently than regular variables inside a string. They MUST be
wrapped with { } to be evaluated.
Third, it's a bad practice to not properly quote your array references.
In other words, the word ticketed should have single quotes around it.
Applying all these things your line should look like this:
$sql = "UPDATE wo SET status = 1 WHERE ticket = {$_POST['ticketed']}";
hth.
chris.
p.s. it's a Very Bad Idea(tm) to grab data directly from $_GET or $_POST
and put it to work before doing any validation on it.
p.p.s. I'm not positive about this but I'd be willing to bet that every
value gathered from $_GET or $_POST is considered a string and not
numeric. Think about it, how would $_POST know that "ticketed" is meant
to be an integer or a string?
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Consider using this....
//
// STDERR logging function
//
function warn( $msg, $die = 0 )
{
$fp = fopen("php://stderr", 'w') or die("Failed to open STDERR");
fwrite($fp, "[".strftime("%Y-%m-%d %T")."] $msg\n")
or die("Failed to write to stderr");
fclose($fp);
if($die)
die($msg);
}
This function will log all output to your Apache BASE error log. It's kind
of like Perl's warn function for PHP.
Also, it's good practice to use assertions... look into assert at
http://php.net/assert
Here is some sample usage...
assert_options (ASSERT_ACTIVE, 1);
assert_options (ASSERT_WARNING, 0);
assert_options (ASSERT_QUIET_EVAL, 1);
assert_options (ASSERT_BAIL, 1);
// Create a handler function
function assert_callback ($file, $line, $code) {
$body = file($file);
if(empty($code))
$code = trim($body[$line-1]);
print "<hr><font color=red>Assertion Failed:</font><br><ul>
File '$file'<br>
Line '$line'<br>
Code '$code'<br></ul>";
warn("Assertion failed ($code) in $file on line $line '$code'");
print "<hr>";
}
// Set up the callback
assert_options (ASSERT_CALLBACK, 'assert_callback');
Regards,
Erik Osterman
http://osterman.com/
-----Original Message-----
From: Robert Sossomon [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 05, 2003 7:38 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP] Adding a log file
I am seeing some errors with a program I wrote and I need to write
everything to a log file that the program is doing.
The following syntax I KNOW is wrong, but not sure they are important to
put here correctly yet.
//script addtocart
$Addcart (info1, info2)
Mysqlquey($addcart)
I am seeing random items NOT being added to my shopping cart. The
reason, I have no clue. I can pull another catgory of items and the
first 20 will do fine, I go back to the first category I have and the
script seems to work correctly but the data is not written to the
shopping cart. Problem with the shopping cart??? I wouldn't think so.
Problem with the add page, I don't see how. So where is the error
coming from? No clue, which is why I want to log everything. I use 3
different add pages so that each form uses a different way to add. This
works for me, and seems to work rather well. But I need to log
everything on the 3 forms to see where the errors are coming from.
TIA!
Robert
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To rest is to rust.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Erik Osterman wrote:
Consider using this....
//
// STDERR logging function
//
function warn( $msg, $die = 0 )
{
$fp = fopen("php://stderr", 'w') or die("Failed to open STDERR");
fwrite($fp, "[".strftime("%Y-%m-%d %T")."] $msg\n")
or die("Failed to write to stderr");
fclose($fp);
if($die)
die($msg);
}
There is also the error_log() and syslog() functions.
http://us2.php.net/error_log
http://us2.php.net/syslog
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
It almost sounds like you've not yet drawn out an object map on a piece of
paper to see for youself how everything is inter-connected. I'm sure this is
the _perfect_ opportunity for using classes, but at the same time will
require some good thought now before you go a head and implement it. Good
object design doesn't just happen, it's thought out.
As for instantiation (creating the objects), don't worry about this just yet
(Unless you're using some gross amount of memory). Very often, the cost for
optimizing your code before it's actually written doesn't help. There are so
many unforeseen inefficiencies you will encounter; simply not allocating a
class here or there will be the least of your worries.
Some advice: Write the code as it makes sense in your mind and on paper.
Then worry about how to optimize it. Even Knuth himself said, "Premature
optimization is the root of all evil"
Best Regards,
Erik Osterman
http://osterman.com/
-----Original Message-----
From: jsWalter [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 21, 2003 4:12 PM
To: [EMAIL PROTECTED]
Subject: [PHP] advise on new class of mine
I'm in the process of building my first "real" class.
43 methods, 23 properties, nearly 1000 lines of codes.
What I would like to know...
Is it better to keep al this in a single file? Or break it up into
sub-classes?
This does have logical sections, so a breakup would be possible, but then
I'm not sure how I would piece it back together.
Also...
Many properties are not required at object instantiation, but I define them
none-the-less. Many are derived from multiple others.
It is better to define all properties, many may never be used, or simply
define them as they are called?
I define them all now, so there is a (ever so) slight hit on cycles for
this.
If I define them as they are called, then each needs a conditional to
process to run each time that GETTER is called.
Or is this "6 of one and half-dozen of another"?
Now, this gets broken up, many of the properties correspond the different
sections. then he properties should be defined as called, because their
package would only be loaded when called.
Am I talking in circles here?
Does anyone have any advise?
Thanks
Walter
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Sounds like what you want is the "in_array" function.
http://us4.php.net/manual/en/function.in-array.php
$cases = array( 5, 15, 30, 60, 90, 120 );
if ( in_array($count, $cases) ) {
EXECUTE PAGE
}
Regards,
Erik Osterman
http://osterman.com/
-----Original Message-----
From: Jason Williard [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 05, 2003 6:42 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Array --> If
I am building a script that I would like to have do a specific task
based on whether specific counts have been reached.
Basically, the script checks for connectivity in a specific port. If
the connectivity fails, it increases the count by 1. It does this every
minute. I would like the script to page me at specific marker points
(i.e. 5, 15, 30, 60, 90, 120, etc). Is there anyway to make an if
statement or something similar to run in any case where the COUNT value
equals one of the numbers in the array?
Example:
$cases = array( 5, 15, 30, 60, 90, 120 );
if ( $count = {ITEM IN $cases} ) {
EXECUTE PAGE
}
Thanks,
Jason Williard
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi all,
I'm sorry, I know this is not the list, to ask this question, but I couldn't find the
right one.
I'm having trouble with BRU. I'm running it for quite a time but it has started
throwing errors. Main problem is, though there's plenty of free space on my tape
media, it says,
Insert vol 2 and press enter
Insert vol 3 and press enter
.......
Dont know, what to do. I googled on it, but no specific answer. If you have a solution
or direct me to some helpful info, I'll be very gratefull. It's really important, so
sorry again for querying at wrong place.
Regards
Nitin
--- End Message ---
--- Begin Message ---
I know this is becoming off-t but just for the curious...
On Fri, 7 Nov 2003 13:43:06 -0600
Eugene Lee <[EMAIL PROTECTED]> wrote:
> On Sat, Nov 08, 2003 at 01:35:40AM +0900, - Edwin - wrote:
> :
> : On 2003.11.7, at 18:37 Asia/Tokyo, Marek Kilimajer wrote:
> :
> : ...[snip]...
> :
> : >Are Kanji and Kana chracter sets?
> :
> : "Kan" -> Chinese + "ji" -> character
> :
> : kana: (quoted from the American Heritage Dictionary)
> : "1. Japanese syllabic writing. The characters are
> simplified kanji
>
> Actually, kana are not "simplified kanji" because it is not
> the case that kana can replace kanji while preserving the
> exact same meaning. In fact, most kana by themselves have
> no meaning.
Well, I'm sure there's a very good reason why the dictionary
I quoted called it "simplified kanji". In fact, there's a
very good why many--if not all--the books that talks about
the subject call it the same way.
Japanese didn't have a native system of writing so they
borrowed from Chinese characters. Those Chinese characters
were used *phonetically* and the meanings were ignored. In
other words, one can say that, during those time /even/
kanjis did NOT have any meaning for the Japanese (person)
since the characters were just used phonetically.
Since each Japanese word had to employ several Chinese
characters, which requires a large number of strokes, they
decided to simplify this bothersome process by using a
cursive, simplified style of kanji.
Then, (just to make the story short) during the Heian period
(794-1185), the simplified characters underwent a further
simplification. Thus, "hiragana" (and a little later,
"katakana") was born.
Actually, just by observing how the "kanas" are written,
you'll notice that:
* The hiragana and katakana for "na"
came from the kanji "na" in "Nara"
(Nara Prefecture).
* The hiragana and katakana for "yu"
came from the kanji "yu" which means
reason, cause, etc.
* All hiragana and katakana has a
corresponding kanji from which
they're derived from.
Now, back to the future...
- E -
__________________________________________________
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo!
http://bb.yahoo.co.jp/
--- End Message ---
--- Begin Message ---
On Fri, 7 Nov 2003 13:36:35 -0600
Eugene Lee <[EMAIL PROTECTED]> wrote:
> On Sat, Nov 08, 2003 at 02:20:00AM +0900, - Edwin - wrote:
> :
> : Besides, there are some issues (for example with
> Shift_JIS) that: "bothers" (with no easy "solution") even
> members of the Japanese PHP: Group ML. (Like the recent
> thread [PHP-users 18803] on: http://www.php.gr.jp/ or
> : http://ns1.php.gr.jp/mailman/listinfo/php-users mentioned
> about the : SJIS trouble.)
>
> Force the end-user not to use Shift-JIS.
Um, you don't have to do that since YOU as the programmer
decides what to use.
> It's a brain-dead
> format used only for internal processing purposes and not
> meant as a for-the-public encoding method. Stick with
> something nice like normal JIS or Unicode.
"Brain-dead format" compared to JIS? Hehe, maybe you're
confused ;) Besides, I guess, more than half of Japanese
sites are written in shift_jis.
Result of a quick Google search:
http://www.io.com/~kazushi/encoding/
Anyway, the easiest way (I find for now) when working with
PHP and Databases (MySQL, etc.) is to use "euc-jp". There are
times though that you are "forced" to use "shift_jis" e.g.
when working with sites for i-mode's browsers. If that's the
case, just use the mb_* functions to convert from euc-jp to
shift_jis...
- E -
__________________________________________________
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo!
http://bb.yahoo.co.jp/
--- End Message ---
--- Begin Message ---
On Sat, Nov 08, 2003 at 06:26:39PM +0900, - Edwin - wrote:
:
: On Fri, 7 Nov 2003 13:43:06 -0600 Eugene wrote:
: >
: > Actually, kana are not "simplified kanji" because it is not
: > the case that kana can replace kanji while preserving the
: > exact same meaning. In fact, most kana by themselves have
: > no meaning.
:
: Well, I'm sure there's a very good reason why the dictionary
: I quoted called it "simplified kanji".
I disagree with the term "simplified kanji". The kana may have been
derived from kanji and evolved over the centuries, but they are no
longer kanji in the sense that they carry any intrinsic meaning by
themselves. Nor can they replace kanji in meaning and function. They
are just phonetic alphabets.
--- End Message ---
--- Begin Message ---
In hopes of bringing the kanji character validation issue back
on topic, can I point out that it doesn't matter *why* someone would
want to do this, or what the origins of kanji and kana are? The
motivations of the original poster shouldn't be in question. Everyone
has their own situations and goals, and what's not important to one
person is important to others. Either what they are asking for is
possible or not, and if it is, it would be enlightening to know how.
I for one am also very interested in hearing possible solutions.
I can think of multiple situations in which checking to see whether a
user inputted kanji or kana would be very useful indeed. And I hope to
learn more by further discussion of the PHP coding required. It would be
a shame if that potential learning was obscured or lost in off topic
theorizing about the origins of the Japanese language.
Optimistically looking forward to seeing more technical discussion on
how to accomplish this.
--
Cheers!
Dave G
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
On 2003.11.8, at 20:32 Asia/Tokyo, Eugene Lee wrote:
On Sat, Nov 08, 2003 at 06:26:39PM +0900, - Edwin - wrote:
:
: On Fri, 7 Nov 2003 13:43:06 -0600 Eugene wrote:
: >
: > Actually, kana are not "simplified kanji" because it is not
: > the case that kana can replace kanji while preserving the
: > exact same meaning. In fact, most kana by themselves have
: > no meaning.
:
: Well, I'm sure there's a very good reason why the dictionary
: I quoted called it "simplified kanji".
I disagree with the term "simplified kanji".
regex - regular expressions
Um, what's so "regular" about it again?
The kana may have been
derived from kanji and evolved over the centuries, but they are no
longer kanji in the sense that they carry any intrinsic meaning by
themselves.
?? Who said that they are kanji?
Kanji are Chinese characters whereas kana are Japanese characters.
Nor can they replace kanji in meaning and function. They
are just phonetic alphabets.
Did I say otherwise?
- E -
PS
Maybe, you can complain here:
http://dictionary.reference.com/search?q=kana
__________________________________________________
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo!
http://bb.yahoo.co.jp/
--- End Message ---
--- Begin Message ---
On 2003.11.8, at 21:51 Asia/Tokyo, Dave G wrote:
In hopes of bringing the kanji character validation issue back
on topic, can I point out that it doesn't matter *why* someone would
want to do this, or what the origins of kanji and kana are? The
motivations of the original poster shouldn't be in question. Everyone
has their own situations and goals, and what's not important to one
person is important to others. Either what they are asking for is
possible or not, and if it is, it would be enlightening to know how.
I think it'd be scary if there's a certain doctor who'd give you a
medicine just because you said you have a headache. I'm sure a
good doctor would ask questions to diagnose what may be causing
it. He might even send you home without giving you any medicine.
Don't be surprised if your headache is gone the next morning.
I for one am also very interested in hearing possible solutions.
I can think of multiple situations in which checking to see whether a
user inputted kanji or kana would be very useful indeed.
Like for example?
And I hope to
learn more by further discussion of the PHP coding required. It would
be
a shame if that potential learning was obscured or lost in off topic
theorizing about the origins of the Japanese language.
First, I'm not theorizing. They're written in history books.
Optimistically looking forward to seeing more technical discussion on
how to accomplish this.
Secondly, didn't I mention that this was recently brought up in the
Japanese PHP Group ML? And there's really NO easy solution for this?
http://ns1.php.gr.jp/pipermail/php-users/2003-October/019236.html
In fact, that "problem" is already an FAQ in that ML--and other MLs as
well since "the need" is not limited to PHP programmers only.
- E -
__________________________________________________
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo!
http://bb.yahoo.co.jp/
--- End Message ---
--- Begin Message ---
On Saturday 08 November 2003 08:21, John Hagstrand wrote:
> Thanks for your snot.
They were surplus to requirements so you're welcome to them.
> The code you wrote below,
>
> > echo fopen("http://www.google.com", 'r');
> > echo fopen("http://news.google.com", 'r');
>
> I've implmented at this url.
> http://www.globalscoop.com/gs/feeds/testUrl.php
>
> You can see the error I'm getting. Would you take a look?
No. Would you mind posting the error you're getting so that everyone can see?
And please confirm that whatever error you're getting is in response to the
exact code as above.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Caution: Keep out of reach of children.
*/
--- End Message ---
--- Begin Message ---
Hello,
I have in a database a date field (this format yyy/mm/dd). I'd like when I
display the value use an another format dd/mm/yyyy (format in europ), could
you tell me if there is a format DateString function ?
Thanks,
Christian,
--- End Message ---
--- Begin Message ---
On Sat, 2003-11-08 at 11:45, Christian Ista wrote:
> Hello,
>
> I have in a database a date field (this format yyy/mm/dd). I'd like when I
> display the value use an another format dd/mm/yyyy (format in europ), could
> you tell me if there is a format DateString function ?
>
> Thanks,
>
> Christian,
http://www.php.net/date
Cheers,
Filip de Waard
--- End Message ---
--- Begin Message ---
On Sat, 2003-11-08 at 15:21, Christian Ista wrote:
> <?php echo mysql_result($result_cat,0,"CATC_DATE");?>
>
> a string like that : 2003-11-07 and I'd like display 07/11/2003
I usually do:
<?
$query = "SELECT UNIX_TIMESTAMP(datefield) as unixtime FROM table";
$timestamp = mysql_result($result, "unixtime");
$date = date("d/m/Y", $timestamp);
echo $date;
?>
Regards,
Filip de Waard
--- End Message ---
--- Begin Message ---
Hello,
how can I read element1, element2 and element3 from array:
a|a:1:{i:1;a:3:{
i:0;s:6:"element1";
i:1;s:5:"element2";
i:2;s:6:"element3";
}}
TNX
--- End Message ---
--- Begin Message ---
dr. zoidberg wrote:
Hello,
how can I read element1, element2 and element3 from array:
a|a:1:{i:1;a:3:{
i:0;s:6:"element1";
i:1;s:5:"element2";
i:2;s:6:"element3";
}}
http://www.php.net/unserialize
--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
-----------------------
"Documentation is like sex: when it is good,
it is very, very good; and when it is bad,
it is better than nothing."
--- End Message ---
--- Begin Message ---
Hi all:
Trying to solve a phpmysql array problem.
Let's say I have a table in mysql format
Column1
Column2
dog
brown
cat
white
cat
black
cat
mixed
pig
black
pig
brown
What kind of (query, array function, loop, etc...) should I use to produce an html
output like this:
1. column1:dog
column2:brown
2. column1:cat
column2: white, black,mixed
3. column1: pig
column2: black, brown
I figure I have to use the implode function.
Thanks in advance
J
---------------------------------
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
--- End Message ---
--- Begin Message ---
Please excuse the previous post. Table unformatted.
Hi all:
Trying to solve a phpmysql array problem.
Let's say I have a table in mysql format
Column1 Columnn2
dog brown
cat white
cat black
cat mixed
pig black
pig brown
What kind of (query, array function, loop, etc...)
should I use to produce an html output like this:
1. column1:dog
column2:brown
2. column1:cat
column2: white, black,mixed
3. column1: pig
column2: black, brown
I figure I have to use the implode function.
Thanks in advance
J
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
--- End Message ---
--- Begin Message ---
Joffrey Leevy wrote:
Please excuse the previous post. Table unformatted.
Hi all:
Trying to solve a phpmysql array problem.
Let's say I have a table in mysql format
Column1 Columnn2
dog brown
cat white
cat black
cat mixed
pig black
pig brown
What kind of (query, array function, loop, etc...)
should I use to produce an html output like this:
1. column1:dog
column2:brown
2. column1:cat
column2: white, black,mixed
3. column1: pig
column2: black, brown
SELECT * FROM thetable GROUP BY column1;
That should work read > http://www.mysql.com/manual
--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
-----------------------
"Documentation is like sex: when it is good,
it is very, very good; and when it is bad,
it is better than nothing."
--- End Message ---
--- Begin Message ---
Burhan Khalid wrote:
SELECT * FROM thetable GROUP BY column1;
That should work read > http://www.mysql.com/manual
SELECT *, GROUP_CONCAT(column2) as column2 FROM thetable GROUP BY column1;
But this requires mysql 4.1. If you don't have mysql 4.1, detect in your
while loop if column1 is not equal to the previous one, then start a new
row.
--- End Message ---
--- Begin Message ---
Hi, is it possible to create a beveled text using GD.
Going through all the classes I have not come across any algorithm which
explains beveled text.
Siddhartha
--- End Message ---
--- Begin Message ---
Well, I'm speaking from imagination here but I imagine the effect could be obtained by
creating a series of layers to one item in a loop, changing the alpha transparency
slightly each time as well as shrinking the size of the image. You'd start with 75ish
alpha level and then loop through one level at a time up a to 100 or something like
that, shrinking the text gradually and building off the same center each time.
Try it and tell me what happens, I am curious.
Cheers,
Nathan
----- Original Message -----
From: Siddhartha Lahiri
To: [EMAIL PROTECTED]
Sent: Saturday, November 08, 2003 8:45 AM
Subject: [PHP] Beveled text
Hi, is it possible to create a beveled text using GD.
Going through all the classes I have not come across any algorithm which
explains beveled text.
Siddhartha
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Sorry for the long post--and the cross-posting to a MySQL list, for
those of you seeing this a second time--but I'm using with difficulty
the 2nd edition of Welling/Thomson's PHP and MySQL Web Development as a
textbook for self-teaching (and I'm at the end of my rope).
After being pleased to work my way thru to Chapter 14, not memorizing
the earlier material, but having some success basically understanding
it--I get to the first "meaty" topic that I was really looking forward
to getting into: the business of authentication.
So I went into MySQL and created the database auth and the table auth,
using the following script:
create database auth;
use auth;
create table auth (
name varchar(10) not null,
pass varchar(30) not null,
primary key (name)
);
insert into auth values
('user', 'pass');
insert into auth values
( 'testuser', password('test123') );
grant select, insert, update, delete
on auth.*
to [EMAIL PROTECTED]
identified by 'rivet';
I used my username that I log into the computer I'm working on--an
offline Powerbook--at the bottom, 'stevet', as well as the password that
belongs to that username, 'rivet'. Since I'm using the test server
'localhost' on the Powerbook, I used that in the code, as well. These
have worked when called for in previous PHP/MySQL exercises, so it's not
something new I invented just for this batch of tutorials.
Next I opened listing 14.2, secretdb.php--placed properly at the root
level for accessing in my test server--in my browser. Here's secretdb.php:
<?php
if(!isset($_POST['name'])&&!isset($_POST['password']))
{
//Visitor needs to enter a name and password
?>
<h1>Please Log In</h1>
This page is secret.
<form method="post" action="secretdb.php">
<table border="1">
<tr>
<th> Username </th>
<td> <input type="text" name="name"> </td>
</tr>
<tr>
<th> Password </th>
<td> <input type="password" name="password"> </td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Log In">
</td>
</tr>
</table>
</form>
<?php
}
else
{
// connect to mysql
$mysql = mysql_connect( 'localhost', 'stevet', 'rivet' );
if(!$mysql)
{
echo 'Cannot connect to database.';
exit;
}
// select the appropriate database
$mysql = mysql_select_db( 'auth' );
if(!$mysql)
{
echo 'Cannot select database.';
exit;
}
// query the database to see if there is a record which matches
$query = "select count(*) from auth where
name = '$name' and
pass = '$password'";
$result = mysql_query( $query );
if(!$result)
{
echo 'Cannot run query.';
exit;
}
$count = mysql_result( $result, 0, 0 );
if ( $count > 0 )
{
// visitor's name and password combination are correct
echo '<h1>Here it is!</h1>';
echo 'I bet you are glad you can see this secret page.';
}
else
{
// visitor's name and password combination are not correct
echo '<h1>Go Away!</h1>';
echo 'You are not authorized to view this resource.';
}
}
?>
I was greeted by the Please Log In screen. I used 'user' as username and
'pass' as the password, as that was one of the two combinations the
first bit of code above inserted into the table auth. After submitting,
I got the customized error message: "Go Away! You are not authorized to
view this resource."
Just to make certain, I substituted 'root' and my root password in both
pieces of code for 'stevet' and 'rivet', and got the same error screen.
I don't understand why either of those username/password combinations
don't work. I mean, they're in the authorization table. And I'm
obviously connecting to the database, as I'm getting past that stage of
the code. Can anyone tell me what I'm too dense to see?
Thanks very much.
Steve Tiano
--- End Message ---
--- Begin Message ---
I'm using Dreamweaver's "Update Record" form wizard to create a record
update page. Most of the fields are "text", one is "file" and I want one of
them to be a "menu". The "menu" field should be populated with the fields
of another table.
Here's the problem... If I leave all of the fields as text input fields,
the form works fine. But, as soon as I change the "manufacturers" field to
a drop-down menu populated with entries from another table, I get the
following error when accessing the page...
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING' in
/home/s/k/user992816/html/RobesonWeb/admin/adminEditSpecials.php on line
106
line 106 reads...
<option value="<?php echo $row_rs_RobesonWebManufacturer['manufacturer']?>"
<?php if (!(strcmp($row_rs_RobesonWebManufacturer['manufacturer'],
"$row_rs_RobesonWebSpecials[\'manufacturer\']"))) {echo "SELECTED";}
?>><?php echo $row_rs_RobesonWebManufacturer['manufacturer']?></option>
Needless to say, this line is embedded in this Php code to create the
drop-down menu...
<select name="manufacturer">
<?php
do {
?>
<option value="<?php echo
$row_rs_RobesonWebManufacturer['manufacturer']?>" <?php if
(!(strcmp($row_rs_RobesonWebManufacturer['manufacturer'],
"$row_rs_RobesonWebSpecials[\'manufacturer\']"))) {echo "SELECTED";}
?>><?php echo $row_rs_RobesonWebManufacturer['manufacturer']?></option>
<?php
} while ($row_rs_RobesonWebManufacturer = mysql_fetch_assoc
$rs_RobesonWebManufacturer));
?>
</select>
What's up? These "drop-downs from another table" work fine in "Add" forms.
They just seem to crap out in "Update" forms. Attached is the entire page
for consulting.
Thanx,
--
Robb Kerr
Digital IGUANA
Helping Digital Artists Achieve their Dreams
http://www.digitaliguana.com
http://www.cancerreallysucks.org
--- End Message ---