php-general Digest 31 Dec 2001 07:50:30 -0000 Issue 1083
Topics (messages 79066 through 79095):
Re: Session troubles
79066 by: Sean LeBlanc
how long will REGISTERED GLOBALS be around?
79067 by: PHP freak
79086 by: Brian Clark
79090 by: PHP freak
79091 by: Brian Clark
Deleting files?
79068 by: Matt Moreton
Including images from Internet
79069 by: Gaylen Fraley
79070 by: Bogdan Stancescu
79078 by: Bogdan Stancescu
graphics libraries on windows
79071 by: Arvydas V.
Bit shifting conversion (Delphi -> PHP)
79072 by: Stefan Pettersson
79076 by: Bogdan Stancescu
mysql_fetch_array
79073 by: Greg Sidelinger
79075 by: Bogdan Stancescu
79077 by: Mehmet Kamil ERISEN
Need some Linux/Apache help
79074 by: Todd Cary
79081 by: Brian Clark
PHP GuestBook - KISGB (Keep It Simple Guestbook) Version 3.0 Released
79079 by: Gaylen Fraley
MySQL problem
79080 by: Good Fella
79082 by: David Jackson
79083 by: Good Fella
79088 by: Brian Clark
79089 by: David Jackson
79092 by: Good Fella
Re: Parsing out numbers from a string
79084 by: Brian Clark
How to convert integers representations of a date to a date format variable
79085 by: Carlos Fernando Scheidecker Antunes
79087 by: Brian Clark
php4 and PHPLib
79093 by: Gerard Samuel
good php sites
79094 by: Dennis Gearon
Re: another tomcat 4.01 problem
79095 by: Vincent Stoessel
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 ---
On 12-29 22:27, David Jackson wrote:
> Sean --
>
> Does you standard (non session) seem to work ok? Such as:
> <?php
> // basic echo of var from form
> echo "We've just echoed var from form\n";
> echo "<p>$stuff</p>";
> echo "<h2>$more_stuff</h2>";
> echo "<h3>$still_more_stuff</h3>";
> ?>
Yes, this works fine. I should have said that before...
> Did you compile Apache and PHP from source? If so
> could you provide me with the ./configure --options you used?
> This is sound like a config/compile problem to me.
This is what phpinfo() reports for PHP:
'./configure' '--with-apxs=/usr/local/sbin/apxs'
'--with-config-file-path=/usr/local/etc' '--enable-versioning'
'--with-system-regex' '--disable-debug' '--enable-track-vars' '--without-gd'
'--without-mysql' '--enable-session' '--with-zlib' '--with-mysql=/usr/local'
'--with-pgsql=/usr/local' '--with-openssl=/usr' '--with-session'
'--prefix=/usr/local' 'i386--freebsd4.4'
I built PHP from the FreeBSD ports collection. When I ran make, in the menu that
comes up, I selected "transparent session", among other options.
As for Apache...I forget how I installed it. It doesn't appear that I built
it from the ports section, so it was either via a package or a tarball - so
I'm doing it from ports right now to be sure. We'll see how that goes.
> You might also want to cross-post to linux-admin mail list?
I'm using FreeBSD. :) I may post to one of the FreeBSD lists eventually, but
they can sometimes get irritatable when it's not on-topic...
--
Sean LeBlanc:[EMAIL PROTECTED] Yahoo:seanleblancathome
ICQ:138565743 MSN:seanleblancathome AIM:sleblancathome
We are born to action; and whatever is capable of suggesting and guiding
action has power over us from the first.
-Charles Horton Cooley
Management QOTD:It's an orthogonal issue to identify the core product families
and staff appropriately for the process innovation, etc.
--- End Message ---
--- Begin Message ---
About PHP 4.1
What I can't tell from the PHP announcement is how long they plan to keep
register_globals around.
In ONE place it says something like "We have no plans to discontinue
register_globals", but in another place it says it might be
discontinued or devalued soon.
It'd be a REAL drag to have to go audit everything I've ever written in PHP to change
all my global variables.
(Especially since I'd been so careful about security while writing them.)
Anyone know what the internal PHP/Zend plans are for it?
--- End Message ---
--- Begin Message ---
* PHP freak ([EMAIL PROTECTED]) [Dec 30. 2001 15:01]:
[...]
> In ONE place it says something like "We have no plans to discontinue
>register_globals", but in another place it says it might be
> discontinued or devalued soon.
I take it as being depreciated and as something we're all going to have
to face with older code as progress is made with PHP. It's probably not
the last time something like this will happen. Happens with Perl, too.
:-\
--
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
Variables won't; constants aren't.
--- End Message ---
--- Begin Message ---
For what it's worth - casting my vote - I would vote that the PHP/Zend people keep
REGISTER_GLOBALS as an option for one main reason:
NEWBIES!
Think of how nice it is for the total newbies to be able to have this first tutorial:
<?php print "Hello $myname"; ?>
<form action="<?php print $PHP_SELF; ?>">
what is your name?
<input type="text" name="myname">
<input type="submit" name="submit" value="submit">
</form>
Think of how many PHP-CURIOUS people it'd turn off if you could ONLY do it with
$_REQUEST["myname"]
Hell - I *still* have to go to the php.net announcement page to remember the syntax of
the new type. It doesn't come naturally. Nothing like $variablename.
I think the EASE of the form example, above, is what got me into PHP in the first
place.
--- End Message ---
--- Begin Message ---
* PHP freak ([EMAIL PROTECTED]) [Dec 30. 2001 21:45]:
> Think of how many PHP-CURIOUS people it'd turn off if you could ONLY do it with
>$_REQUEST["myname"]
Hell, I have to admit, that is pretty darn ugly.
--
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
Sure FAT32 corrupts your files, but look how fast it is.
--- End Message ---
--- Begin Message ---
Hey guys. Any insight into this problem im experiencing would be much appriciated...
I installed some software on my web space a while back, I ran a script and it
extracted some files from a tar ball I had uploaded. This was all designed to make
the package easy to install and set up. The idea being you just uploaded the tarball
and a script to set it all up. The web server does the rest.
Well now I have a problem that I am trying to delete them. I cant delete them using
my FTP access to my web space, because I dont have the right permissions. I wrote a
script to tell me information about these files, it reports back that the owner is
"apache" and the group is "apache".
I wrote a simple script something like this:
<?php
@unlink($HTTP_GET_VARS[file]);
?>
This doesnt work on files that I own, let alone files that the web server owns in my
user space. What am I doing wrong?
Thanks in advanced.
Matt
--- End Message ---
--- Begin Message ---
Obviously, including an image from another page can be accomplished with an
HTML tag. However, it seems that there are some inherent issues with doing
this.
How do you keep someone from linking a hi-res image and causing your browser
to take forever to return, if you're on a dial-up? Is there someway that
PHP can determine the size, via an fopen("http://a.c.com") call or a socket?
Or am I totally off base with the need/approach? I'm not looking to pilfer
here. I want to allow people to leave a link to their image and then
display their picture, as opposed to an icon that links to their picture.
Since there may be several different ones on a page, I would expect that
you'd have to pre-assemble your page and use PHP to determine size,
validity, etc., if that is possible?
Is this possible or do the pictures need to exist on the server?
Thanks,
--
Gaylen
--- End Message ---
--- Begin Message ---
If you're really serious about implementing this, it can be done using socket
functions and basically creating a crippled browser's functions to only retrieve
files.
If you want to go on in this direction, I'm able to help -- just let me know
what details you need.
Bogdan
Gaylen Fraley wrote:
> Obviously, including an image from another page can be accomplished with an
> HTML tag. However, it seems that there are some inherent issues with doing
> this.
--- End Message ---
--- Begin Message ---
Gaylen wrote:
> Check the validity of the link.
This is inherent to the process -- no need to worry - you just have to include
some error fallback code in the process.
> Check the size. If less than a particular size, then PHP will
> resize/resample it and display a stndard Avatar sized icon.
> If too large, then disallow it.
Ok, seems like I've got it right.
> Can this be done without having to d/l the picture first?
Obviously not -- how could you possibly resize an image you don't have?!
> Can the Windoze
> PHP implementation handle it, as well as the *nix?
Yes, but if you intend to run the same code for both you'll have to either make
sure you have gd installed on both or that you run distinct programs for
resizing based on the OS.
So, what you have to code is:
1. Send a HTTP request to the server the user is pointing to in order to
retrieve the image;
2. Retrieve the image;
3. Check the image size;
4. Resample the image;
5. Store the image in a database/directory;
6. Display the image.
Technical details:
You'll have to separate the link the user passes in two parts: the server and
the path within the server. I suggest using function parse_URL (under "URL
Functions" in the manual) for this job.
Then you'll have to send the actual request. You should use a piece of code
similar to the one below for this job:
<?
function getImageFile($host,$file)
{
$request="GET $file HTTP/1.0\r\n"; // This is the path part of the link
$request.="Host=$host\r\n\r\n"; // This is the server part of the link
// Now let's try connecting:
$fp=fsockopen($host, 80, $errno, $errstr, 30);
// Let's see if we made it
if (!$fp)
{
return(false);
}
else
{
// If we made it, let's send the request:
fputs($fp, $request);
while (!feof($fp))
{
$response.=fgets($fp, 128);
}
fclose($fp);
return($response);
}
}
?>
So, we've solved point (2) in the process -- we now have the image file! All you
have to check the size of the string returned by this function, store it,
resample the image if needed and display it.
Let me know if I can be of further assistance.
Bogdan
--- End Message ---
--- Begin Message ---
Has anybody succesfully installed all graphic libraries on windows platform ? Maybe
you can sent me some links for step by step installation or help any way ?
Thnx
--- End Message ---
--- Begin Message ---
Hello all,
I'm trying to convert a function done in Delphi (pascal) to PHP. This
function is part of simple text encryption/decryption method. However, I
have a really hard time to make this work in PHP. This is the Delphi code:
Function RotateBits(C: Char; Bits: Integer): Char;
var
SI : Word;
begin
Bits := Bits mod 8;
// Are we shifting left?
if Bits < 0 then
begin
// Put the data on the right half of a Word (2 bytes)
SI := MakeWord(Byte(C),0);
// Now shift it left the appropriate number of bits
SI := SI shl Abs(Bits);
end
else
begin
// Put the data on the left half of a Word (2 bytes)
SI := MakeWord(0,Byte(C));
// Now shift it right the appropriate number of bits
SI := SI shr Abs(Bits);
end;
// Finally, Swap the bytes
SI := Swap(SI);
// And OR the two halves together
SI := Lo(SI) or Hi(SI);
Result := Chr(SI);
end;
and this the beginning of my attempt to do the same thing in PHP:
function RotateBits($C, $Bits) {
$Bits = $Bits % 8;
if ($Bits < 0 ) {
$C = $C << abs($Bits);
} else {
$C = $C >> abs($Bits);
}
return chr($C);
}
In the Delphi code the MakeWord function is a macro:
#define MAKEWORD(a, b) \ ((WORD) (((BYTE) (a)) | ((WORD) ((BYTE) (b))) <<
8))
And Swap exchanges the high order byte with the low order byte of the word.
Now my question is, how can I work with bytes and words in PHP? The closest
I've found is just the integer, that may be of different sizes depending on
system. Or, as a workaround, is there any way to detect the number of bytes
an integer is on the current system?
Thanks in advance.
Best regards,
Stefan Pettersson
--- End Message ---
--- Begin Message ---
Why do you need word specifically? I personally had a hard time with PHP in the
beginning exactly because I migrated from the Turbo Pascal/Dephi environment.
Just learn how to deal with the new environment: use larger data types and
shift right the byte in order to create a word and use logical "and" with 65535
in order to mask larger-than-word values.
Bogdan
Stefan Pettersson wrote:
> Hello all,
>
> I'm trying to convert a function done in Delphi (pascal) to PHP. This
> function is part of simple text encryption/decryption method. However, I
> have a really hard time to make this work in PHP. This is the Delphi code:
>
> Function RotateBits(C: Char; Bits: Integer): Char;
> var
> SI : Word;
> begin
> Bits := Bits mod 8;
> // Are we shifting left?
> if Bits < 0 then
> begin
> // Put the data on the right half of a Word (2 bytes)
> SI := MakeWord(Byte(C),0);
> // Now shift it left the appropriate number of bits
> SI := SI shl Abs(Bits);
> end
> else
> begin
> // Put the data on the left half of a Word (2 bytes)
> SI := MakeWord(0,Byte(C));
> // Now shift it right the appropriate number of bits
> SI := SI shr Abs(Bits);
> end;
> // Finally, Swap the bytes
> SI := Swap(SI);
> // And OR the two halves together
> SI := Lo(SI) or Hi(SI);
> Result := Chr(SI);
> end;
>
> and this the beginning of my attempt to do the same thing in PHP:
>
> function RotateBits($C, $Bits) {
> $Bits = $Bits % 8;
>
> if ($Bits < 0 ) {
> $C = $C << abs($Bits);
> } else {
> $C = $C >> abs($Bits);
> }
>
> return chr($C);
> }
>
> In the Delphi code the MakeWord function is a macro:
> #define MAKEWORD(a, b) \ ((WORD) (((BYTE) (a)) | ((WORD) ((BYTE) (b))) <<
> 8))
> And Swap exchanges the high order byte with the low order byte of the word.
>
> Now my question is, how can I work with bytes and words in PHP? The closest
> I've found is just the integer, that may be of different sizes depending on
> system. Or, as a workaround, is there any way to detect the number of bytes
> an integer is on the current system?
>
> Thanks in advance.
>
> Best regards,
> Stefan Pettersson
>
> --
> PHP General 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]
--- End Message ---
--- Begin Message ---
Ok I have use mysql_fetch_array to dump the results of a select query with a
join in it.
if my tables contain a column with the same name how can I distinguish from
them. I'm used to
table_name.value method in other languages but when I tried
$row['table_name.value'] I don't get any values.
can anyone point me in the right direction.
--- End Message ---
--- Begin Message ---
If everything else fails, you should consider using mysql_fetch_row() instead.
Bogdan
Greg Sidelinger wrote:
> Ok I have use mysql_fetch_array to dump the results of a select query with a
> join in it.
> if my tables contain a column with the same name how can I distinguish from
> them.
--- End Message ---
--- Begin Message ---
Hi,
In your SQL, you can say
select t1.col colt1, t2.col colt2
from table1 t1, table2 t2
where t1.something = t2.samething
In other words, you can name your columns differently in your select clause.
I
Bogdan Stancescu <[EMAIL PROTECTED]> wrote: If everything else fails, you should consider
using mysql_fetch_row() instead.
Bogdan
Greg Sidelinger wrote:
> Ok I have use mysql_fetch_array to dump the results of a select query with a
> join in it.
> if my tables contain a column with the same name how can I distinguish from
> them.
--
PHP General 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]
Mehmet Erisen
http://www.erisen.com
---------------------------------
Do You Yahoo!?
Send your FREE holiday greetings online at Yahoo! Greetings.
--- End Message ---
--- Begin Message ---
Coming from a Windows background, I am having difficulty understanding
rpm's, compiling, and making packages. My hope is that someone will
have the patience to take me through the steps, since the HowTo's are
out of date and do not address my current Red Hat 7.2 environment.
With Red Hat 7.2 installed, Apache is installed along with PHP 4.0.6,
however, Interbase is not installed Here is what I have done so far:
I did a "rpm -qa | grep php" and found the rpm that was
installed.(php-4.0.6-7). When I tried "rpm -e php-4.0.6-7", I received
a list of php modules that were dependent on it. So, I "erased" each of
those and finally did the "rpm -e php-4.0.6-7". Then I put
php-4.0.6-7.src.rpm into /tmp and did a "rpm -i php-4.0.6-7.rpm" which
put a tar'd file into /usr/src/redhat/SOURCES.
I did "tar -xzvf /usr/src/redhat/SOURCES/php-4.0.6pl1.tar.gz" which
created a directory /tmp/php-4.0.6. I cd'd into that directory and did
a ./configure --with-interbase=/opt/interbase
--with-apache=/usr/include/apache
After quite a period, I received a "Thank you for using PHP" message. I
followed this with a "make" and a "make install".
Now Apache does not respond to a "testphp.php" script that contains
"phoinfo()" and it use to.
What have I missed.........????
Todd
--
Todd Cary
Ariste Software
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
* Todd Cary ([EMAIL PROTECTED]) [Dec 30. 2001 19:22]:
> I did "tar -xzvf /usr/src/redhat/SOURCES/php-4.0.6pl1.tar.gz" which
> created a directory /tmp/php-4.0.6. I cd'd into that directory and did
> a ./configure --with-interbase=/opt/interbase
> --with-apache=/usr/include/apache
Are you sure the entire Apache source code is in /usr/include/apache?
I believe you wanted --with-apxs rather than --with-apache. If you
really wanted --with-apache, and you know the difference, then you will
also need to cd into the apache source directory, and configure apache
with --activate-module=src/modules/php4/libphp4.a, then make and install
Apache again.
Using --with-apache builds PHP as a static module. --with-apxs builds
PHP as a DSO -- a shared module that can be loaded and unloaded via
httpd.conf using the LoadModule directive.
If you use --with-apxs, when configuring PHP, after you make install, it
will install a PHP module in your *current* Apache install's modules
directory, and it may attempt to update your httpd.conf with the correct
LoadModule line if needed.
> After quite a period, I received a "Thank you for using PHP" message. I
> followed this with a "make" and a "make install".
That "prepped" the PHP module to be included into httpd when you build
Apache. You installed PHP into /usr/local/apache/src (or a similar
path).
> Now Apache does not respond to a "testphp.php" script that contains
> "phoinfo()" and it use to.
That's because PHP isn't installed as an Apache module yet, or you
haven't rebuilt Apache yet.
--
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
Imminent Death of the Net Predicted. GIFs at 11.
--- End Message ---
--- Begin Message ---
I have released version 3.0 of my KISGB.
KISGB is a PHP guestbook program that does not require sessions, cookies, or
an rdbms. Can be Public or Private through HTTP Authentication. Automated
install script, fully customizable, clean, and fast. Separate multiple
logging capabilty for tracking anything! Includes web-based password
protected Admin functionality, along with email notification, greeting, ip
logging, ip banning, bad word filter, smileys, allowable html tags in
comments, next/previous, etc. Themes for controlling appearance that allow
for background colors, images, animations, etc. Language support for Dutch,
English, French, German, Polish, Portuguese, Spanish, and Surinam.
--
Gaylen
[EMAIL PROTECTED]
Home http://www.gaylenandmargie.com/
PHP KISGB v3.0 Guest Book http://www.gaylenandmargie.com/phpwebsite/
--- End Message ---
--- Begin Message ---
Hello,
I am extremely new to MySQL and have never managed to get working
smoothly with PHP before. I am trying really hard to understand
how to work it, and am almost there.
I have a problem which I do not know how to resolve and was
wondering if anybody could help me. I have no idea what is wrong
with the code and why I am getting the error message;
Warning: Supplied argument is not a valid MySQL result resource in
C:\apache\htdocs\sams\chapter10\results.php on line 47
I am currently using a book to aid me with MySQL, and this is an
example from the book. It does not seem to work and I have no idea
what I may have done wrong to obtain this warning.
I have changed my login and password to question marks.
<?
if (!$searchtype || !$searchterm)
{
echo "You have not entered search details. Please go back and try
again.";
exit;
}
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
@ $db = mysql_pconnect("mesh", "bookorama", "bookorama123");
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("booktest");
$query = "select * from booktest where ".$searchtype." like
'%".$searchterm."%'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p>Number of books found: ".$num_results."</p>";
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<p><strong>".($i+1).". Title: ";
echo stripslashes($row["title"]);
echo "</strong><br>Author: ";
echo stripslashes($row["author"]);
echo "<br>ISBN: ";
echo stripslashes($row["isbn"]);
echo "<br>Price: ";
echo stripslashes($row["price"]);
echo "</p>";
}
?>
The problem seems to be around the lines of code;
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
Any assistance is appreciated.
Yours,
GF.
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
--- End Message ---
--- Begin Message ---
Here's the example from the PHP manual:
The tutorial here are very helpfull:
http://www.melonfire.com/community/columns/trog/
-- David
<?php
// Connecting, selecting database
$link = mysql_connect("mysql_host", "mysql_login", "mysql_password")
or die("Could not connect");
print "Connected successfully";
mysql_select_db("my_database")
or die("Could not select database");
// Performing SQL query
$query = "SELECT * FROM my_table";
$result = mysql_query($query)
or die("Query failed");
// Printing results in HTML
print "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td>$col_value</td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";
// Closing connection
mysql_close($link);
?>
> Hello,
>
> I am extremely new to MySQL and have never managed to get working
> smoothly with PHP before. I am trying really hard to understand
> how to work it, and am almost there.
>
> I have a problem which I do not know how to resolve and was
> wondering if anybody could help me. I have no idea what is wrong
> with the code and why I am getting the error message;
>
> Warning: Supplied argument is not a valid MySQL result resource in
> C:\apache\htdocs\sams\chapter10\results.php on line 47
>
> I am currently using a book to aid me with MySQL, and this is an
> example from the book. It does not seem to work and I have no idea what
> I may have done wrong to obtain this warning.
>
> I have changed my login and password to question marks.
>
> <?
>
> if (!$searchtype || !$searchterm)
>
> {
> echo "You have not entered search details. Please go back and try
> again.";
>
> exit;
>
> }
>
>
> $searchtype = addslashes($searchtype);
>
> $searchterm = addslashes($searchterm);
>
> @ $db = mysql_pconnect("mesh", "bookorama", "bookorama123");
>
> if (!$db)
>
> {
> echo "Error: Could not connect to database. Please try again
> later.";
>
> exit;
>
> }
>
> mysql_select_db("booktest");
>
> $query = "select * from booktest where ".$searchtype." like
> '%".$searchterm."%'";
>
> $result = mysql_query($query);
>
> $num_results = mysql_num_rows($result);
>
> echo "<p>Number of books found: ".$num_results."</p>";
>
> for ($i=0; $i <$num_results; $i++)
>
> {
>
> $row = mysql_fetch_array($result);
>
> echo "<p><strong>".($i+1).". Title: ";
>
> echo stripslashes($row["title"]);
>
> echo "</strong><br>Author: ";
>
> echo stripslashes($row["author"]);
>
> echo "<br>ISBN: ";
>
> echo stripslashes($row["isbn"]);
>
> echo "<br>Price: ";
>
> echo stripslashes($row["price"]);
>
> echo "</p>";
>
> }
>
> ?>
>
> The problem seems to be around the lines of code;
>
> $result = mysql_query($query);
>
> $num_results = mysql_num_rows($result);
>
> Any assistance is appreciated.
>
> Yours,
>
> GF.
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
>
>
> --
> PHP General 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]
--
--- End Message ---
--- Begin Message ---
Hiya,
Thanks for the quick reply. I used the PHP manual example and it connects
to the database successfully but cannot select the database.
I'm not sure why this is? I've looked hard at it and I cannot see where I have
gone wrong.
Thanks.
GF.
----- Original Message -----
From: David Jackson
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, December 31, 2001 1:48 AM
Subject: Re: [PHP] MySQL problem
Here's the example from the PHP manual:
The tutorial here are very helpfull:
http://www.melonfire.com/community/columns/trog/
-- David
<?php
// Connecting, selecting database
$link = mysql_connect("mysql_host", "mysql_login", "mysql_password")
or die("Could not connect");
print "Connected successfully";
mysql_select_db("my_database")
or die("Could not select database");
// Performing SQL query
$query = "SELECT * FROM my_table";
$result = mysql_query($query)
or die("Query failed");
// Printing results in HTML
print "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td>$col_value</td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";
// Closing connection
mysql_close($link);
?>
> Hello,
>
> I am extremely new to MySQL and have never managed to get working
> smoothly with PHP before. I am trying really hard to understand
> how to work it, and am almost there.
>
> I have a problem which I do not know how to resolve and was
> wondering if anybody could help me. I have no idea what is wrong
> with the code and why I am getting the error message;
>
> Warning: Supplied argument is not a valid MySQL result resource in
> C:\apache\htdocs\sams\chapter10\results.php on line 47
>
> I am currently using a book to aid me with MySQL, and this is an
> example from the book. It does not seem to work and I have no idea what
> I may have done wrong to obtain this warning.
>
> I have changed my login and password to question marks.
>
> <?
>
> if (!$searchtype || !$searchterm)
>
> {
> echo "You have not entered search details. Please go back and try
> again.";
>
> exit;
>
> }
>
>
> $searchtype = addslashes($searchtype);
>
> $searchterm = addslashes($searchterm);
>
> @ $db = mysql_pconnect("mesh", "bookorama", "bookorama123");
>
> if (!$db)
>
> {
> echo "Error: Could not connect to database. Please try again
> later.";
>
> exit;
>
> }
>
> mysql_select_db("booktest");
>
> $query = "select * from booktest where ".$searchtype." like
> '%".$searchterm."%'";
>
> $result = mysql_query($query);
>
> $num_results = mysql_num_rows($result);
>
> echo "<p>Number of books found: ".$num_results."</p>";
>
> for ($i=0; $i <$num_results; $i++)
>
> {
>
> $row = mysql_fetch_array($result);
>
> echo "<p><strong>".($i+1).". Title: ";
>
> echo stripslashes($row["title"]);
>
> echo "</strong><br>Author: ";
>
> echo stripslashes($row["author"]);
>
> echo "<br>ISBN: ";
>
> echo stripslashes($row["isbn"]);
>
> echo "<br>Price: ";
>
> echo stripslashes($row["price"]);
>
> echo "</p>";
>
> }
>
> ?>
>
> The problem seems to be around the lines of code;
>
> $result = mysql_query($query);
>
> $num_results = mysql_num_rows($result);
>
> Any assistance is appreciated.
>
> Yours,
>
> GF.
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
>
>
> --
> PHP General 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]
--
--- End Message ---
--- Begin Message ---
* GoodFella ([EMAIL PROTECTED]) [Dec 30. 2001 21:10]:
> Thanks for the quick reply. I used the PHP manual example and it connects
> to the database successfully but cannot select the database.
So you are using this line:
> > mysql_select_db("booktest");
Correct? What does the server "say" in return? What is the error
message?
--
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
You can't put a bag over someone's personality.
--- End Message ---
--- Begin Message ---
I almost forgot add a or mysql_error() for each line like this:
<?php
// database connect script
$dbhostname = "localhost";
$dbuser = "db_user_name";
$dbpasswd = "db_password";
$dbname= "db_name";
$link = mysql_connect("$dbhostname", "$dbuser", "$dbpasswd")
echo mysql_error();
mysql_select_db("$dbname")
echo mysql_error();
?>
This will return "human readable error messges"
Can you onto mysql database from command.
mysql -u root -p mysql
or mysql -u root mysql # A root password isn't usally get during install.
if so:
>select user,host,password from user;
then:
select user,host,db from db;
My quesss you don't have any permission for the databases or to connect
to local host. If this is correct do:
GRANT ALL on db_name.* TO you@local host idendified by 'your_password';
> Hiya,
>
> Thanks for the quick reply. I used the PHP manual example and it
> connects to the database successfully but cannot select the database.
>
> I'm not sure why this is? I've looked hard at it and I cannot see where
> I have gone wrong.
>
> Thanks.
>
> GF.
> ----- Original Message -----
> From: David Jackson
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Sent: Monday, December 31, 2001 1:48 AM
> Subject: Re: [PHP] MySQL problem
>
>
> Here's the example from the PHP manual:
> The tutorial here are very helpfull:
> http://www.melonfire.com/community/columns/trog/
>
> -- David
>
> <?php
> // Connecting, selecting database
> $link = mysql_connect("mysql_host", "mysql_login", "mysql_password")
> or die("Could not connect");
> print "Connected successfully";
> mysql_select_db("my_database")
> or die("Could not select database");
>
> // Performing SQL query
> $query = "SELECT * FROM my_table";
> $result = mysql_query($query)
> or die("Query failed");
>
> // Printing results in HTML
> print "<table>\n";
> while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
> print "\t<tr>\n";
> foreach ($line as $col_value) {
> print "\t\t<td>$col_value</td>\n";
> }
> print "\t</tr>\n";
> }
> print "</table>\n";
>
> // Closing connection
> mysql_close($link);
> ?>
>
>
>
>
> > Hello,
> >
> > I am extremely new to MySQL and have never managed to get working
> > smoothly with PHP before. I am trying really hard to understand how
> > to work it, and am almost there.
> >
> > I have a problem which I do not know how to resolve and was
> > wondering if anybody could help me. I have no idea what is wrong
> > with the code and why I am getting the error message;
> >
> > Warning: Supplied argument is not a valid MySQL result resource in
> > C:\apache\htdocs\sams\chapter10\results.php on line 47
> >
> > I am currently using a book to aid me with MySQL, and this is an
> > example from the book. It does not seem to work and I have no idea
> > what I may have done wrong to obtain this warning.
> >
> > I have changed my login and password to question marks.
> >
> > <?
> >
> > if (!$searchtype || !$searchterm)
> >
> > {
> > echo "You have not entered search details. Please go back and
> > try
> > again.";
> >
> > exit;
> >
> > }
> >
> >
> > $searchtype = addslashes($searchtype);
> >
> > $searchterm = addslashes($searchterm);
> >
> > @ $db = mysql_pconnect("mesh", "bookorama", "bookorama123");
> >
> > if (!$db)
> >
> > {
> > echo "Error: Could not connect to database. Please try again
> > later.";
> >
> > exit;
> >
> > }
> >
> > mysql_select_db("booktest");
> >
> > $query = "select * from booktest where ".$searchtype." like
> > '%".$searchterm."%'";
> >
> > $result = mysql_query($query);
> >
> > $num_results = mysql_num_rows($result);
> >
> > echo "<p>Number of books found: ".$num_results."</p>";
> >
> > for ($i=0; $i <$num_results; $i++)
> >
> > {
> >
> > $row = mysql_fetch_array($result);
> >
> > echo "<p><strong>".($i+1).". Title: ";
> >
> > echo stripslashes($row["title"]);
> >
> > echo "</strong><br>Author: ";
> >
> > echo stripslashes($row["author"]);
> >
> > echo "<br>ISBN: ";
> >
> > echo stripslashes($row["isbn"]);
> >
> > echo "<br>Price: ";
> >
> > echo stripslashes($row["price"]);
> >
> > echo "</p>";
> >
> > }
> >
> > ?>
> >
> > The problem seems to be around the lines of code;
> >
> > $result = mysql_query($query);
> >
> > $num_results = mysql_num_rows($result);
> >
> > Any assistance is appreciated.
> >
> > Yours,
> >
> > GF.
> >
> > _________________________________________________________________
> > Chat with friends online, try MSN Messenger:
> > http://messenger.msn.com
> >
> >
> > --
> > PHP General 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]
>
>
> --
--
--- End Message ---
--- Begin Message ---
Thanks so much guys,
It was my user permissions all along. Funnily enough the book
gives you guidelines on how to set them up, and sets up a fair
few... but for some reason they selected the wrong user to use.
Thanks very much for your help David and Brian- much appreciated.
Yours,
GF
----- Original Message -----
From: David Jackson
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED] ; [EMAIL PROTECTED]
Sent: Monday, December 31, 2001 2:41 AM
Subject: Re: [PHP] MySQL problem
I almost forgot add a or mysql_error() for each line like this:
<?php
// database connect script
$dbhostname = "localhost";
$dbuser = "db_user_name";
$dbpasswd = "db_password";
$dbname= "db_name";
$link = mysql_connect("$dbhostname", "$dbuser", "$dbpasswd")
echo mysql_error();
mysql_select_db("$dbname")
echo mysql_error();
?>
This will return "human readable error messges"
Can you onto mysql database from command.
mysql -u root -p mysql
or mysql -u root mysql # A root password isn't usally get during install.
if so:
>select user,host,password from user;
then:
select user,host,db from db;
My quesss you don't have any permission for the databases or to connect
to local host. If this is correct do:
GRANT ALL on db_name.* TO you@local host idendified by 'your_password';
> Hiya,
>
> Thanks for the quick reply. I used the PHP manual example and it
> connects to the database successfully but cannot select the database.
>
> I'm not sure why this is? I've looked hard at it and I cannot see where
> I have gone wrong.
>
> Thanks.
>
> GF.
> ----- Original Message -----
> From: David Jackson
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Sent: Monday, December 31, 2001 1:48 AM
> Subject: Re: [PHP] MySQL problem
>
>
> Here's the example from the PHP manual:
> The tutorial here are very helpfull:
> http://www.melonfire.com/community/columns/trog/
>
> -- David
>
> <?php
> // Connecting, selecting database
> $link = mysql_connect("mysql_host", "mysql_login", "mysql_password")
> or die("Could not connect");
> print "Connected successfully";
> mysql_select_db("my_database")
> or die("Could not select database");
>
> // Performing SQL query
> $query = "SELECT * FROM my_table";
> $result = mysql_query($query)
> or die("Query failed");
>
> // Printing results in HTML
> print "<table>\n";
> while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
> print "\t<tr>\n";
> foreach ($line as $col_value) {
> print "\t\t<td>$col_value</td>\n";
> }
> print "\t</tr>\n";
> }
> print "</table>\n";
>
> // Closing connection
> mysql_close($link);
> ?>
>
>
>
>
> > Hello,
> >
> > I am extremely new to MySQL and have never managed to get working
> > smoothly with PHP before. I am trying really hard to understand how
> > to work it, and am almost there.
> >
> > I have a problem which I do not know how to resolve and was
> > wondering if anybody could help me. I have no idea what is wrong
> > with the code and why I am getting the error message;
> >
> > Warning: Supplied argument is not a valid MySQL result resource in
> > C:\apache\htdocs\sams\chapter10\results.php on line 47
> >
> > I am currently using a book to aid me with MySQL, and this is an
> > example from the book. It does not seem to work and I have no idea
> > what I may have done wrong to obtain this warning.
> >
> > I have changed my login and password to question marks.
> >
> > <?
> >
> > if (!$searchtype || !$searchterm)
> >
> > {
> > echo "You have not entered search details. Please go back and
> > try
> > again.";
> >
> > exit;
> >
> > }
> >
> >
> > $searchtype = addslashes($searchtype);
> >
> > $searchterm = addslashes($searchterm);
> >
> > @ $db = mysql_pconnect("mesh", "bookorama", "bookorama123");
> >
> > if (!$db)
> >
> > {
> > echo "Error: Could not connect to database. Please try again
> > later.";
> >
> > exit;
> >
> > }
> >
> > mysql_select_db("booktest");
> >
> > $query = "select * from booktest where ".$searchtype." like
> > '%".$searchterm."%'";
> >
> > $result = mysql_query($query);
> >
> > $num_results = mysql_num_rows($result);
> >
> > echo "<p>Number of books found: ".$num_results."</p>";
> >
> > for ($i=0; $i <$num_results; $i++)
> >
> > {
> >
> > $row = mysql_fetch_array($result);
> >
> > echo "<p><strong>".($i+1).". Title: ";
> >
> > echo stripslashes($row["title"]);
> >
> > echo "</strong><br>Author: ";
> >
> > echo stripslashes($row["author"]);
> >
> > echo "<br>ISBN: ";
> >
> > echo stripslashes($row["isbn"]);
> >
> > echo "<br>Price: ";
> >
> > echo stripslashes($row["price"]);
> >
> > echo "</p>";
> >
> > }
> >
> > ?>
> >
> > The problem seems to be around the lines of code;
> >
> > $result = mysql_query($query);
> >
> > $num_results = mysql_num_rows($result);
> >
> > Any assistance is appreciated.
> >
> > Yours,
> >
> > GF.
> >
> > _________________________________________________________________
> > Chat with friends online, try MSN Messenger:
> > http://messenger.msn.com
> >
> >
> > --
> > PHP General 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 General 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]
--- End Message ---
--- Begin Message ---
* John Weez ([EMAIL PROTECTED]) [Dec 30. 2001 03:23]:
> I have a small program which captures the output of a webpage and puts the
> data in to a string variable.
> I then use teh strip tags function of php to clean it up a bit.
> then i want to use regular expressions to extract all the numbers from the
> page ..they are like this usually numbers.numbers (IE: 40.40 ).
> For some reason my expressions are not matching anything in the string
> unless i type exactly what i am looking for... could the fact that there
> are line reurns in the string be causing a problem? or do i need to
> somehow tell php to goto the next line?
How are you grabbing all the data from the page?
> I had an older version of the program which saved teh data to a file and
> then PhP scanned the file line by line..this worked...but i'm trying to
> make a more elegant solution that won;t kill my hard drive faster ;)
It's going to use a bit of memory to search an entire page with a
regular expression. It's probably going to be slow(er) no matter how you
slice it.
I would use the PCRE functions; preg_match_all() probably..
Look over these:
<http://www.php.net/manual/en/pcre.pattern.modifiers.php>
I think you'll want to use m (and g is default, as the comment says).
Something like this may work:
<?php
/* untested */
preg_match_all('/([0-9]+\.[0-9]+)/m',$string,$matches);
while(list(,$match) = each($matches[0]))
{
print "$match\n";
}
?>
--
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
Recursive: Adj. See Recursive.
--- End Message ---
--- Begin Message ---
Hello All,
I would like to convert integers like the day, month and year to a date representation
to store it in a session variable.
There's a form where the user posts day, month and year. So then I run
checkdate($month,$day,$year) and make sure the date is valid.
So, let's say I have 12 for month, 30 for day and 2001 as year. Do I have to create a
timestamp? How to create a
TimeStamp?
I need to store it as 30/12/2001 (but not a string) not only on a session variable but
also to make it easier to work with a MySQL table.
After that I want to play with it as a string so I will use the date() function,
that's why it is important to save it as a validade date format value.
Any sugestions?
Thank you in advance,
Carlos Fernando.
Linux User #207984
--- End Message ---
--- Begin Message ---
* Carlos Fernando Scheidecker Antunes ([EMAIL PROTECTED]) [Dec 30. 2001 21:11]:
> So, let's say I have 12 for month, 30 for day and 2001 as year. Do I have to create
>a timestamp? How to create a
> TimeStamp?
strtotime() can convert it into a unix timestamp.
> I need to store it as 30/12/2001 (but not a string) not only on a session variable
>but also to make it easier to work with a MySQL table.
For MySQL, this may help:
<http://marc.theaimsgroup.com/?l=php-general&m=100927056511210&w=2>
--
Brian Clark | Avoiding the general public since 1805!
Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
Never try to out stare a cat. They've got no eyelids.
--- End Message ---
--- Begin Message ---
I came across an application "sourcewell" and it requires PHPLib.
My server has php4 on it. I never played with php3 before (dont know if
I want to), and I didn't see anything in its docs about php4
Is it possible to run this thing on a box with php4??
Thanks
--- End Message ---
--- Begin Message ---
other than putting the 'next question' link too far from the question
selection zone, this is a cool php site.
http://verticalmove.bpnetworks.com/module.php?jobID=68689&modNum=13
--
-----------------------------------------------------------------
Look lovingly upon the present,
for it holds the only things that are forever true.
-----------------------------------------------------------------
How many Microsoft programmers does it take to screw in a light bulb?
None. Let's define darkness as the new industry standard
-----------------------------------------------------------------
Sincerely, Dennis Gearon (Kegley)
--- End Message ---
--- Begin Message ---
OK, here is a little more data:
my system is running redhat (i386 )6.2 with glibc 2.1.3
I have the latest jdk 1.3.1 from java.sun.com
Tomcat seems to load and set up my php servlet context just fine:
XmlMapper: pop org.apache.catalina.core.StandardWrapper
XmlMapper: org.apache.catalina.core.StandardContext.addServletMapping( *.php, php)
XmlMapper: org.apache.catalina.core.StandardContext.addServletMapping( *.phps,
php-formatter)
but when I try accessing a php script, tomcat crashes:
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : 11 occurred at PC=0x36a573fe
Function name=Java_net_php_reflect_setEnv
Library=/usr/local/phpservlet/lib/php/libphp4.so
Current Java thread:
at net.php.servlet.send(Native Method)
at net.php.servlet.service(servlet.java:162)
at net.php.servlet.service(servlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
Has anyone gotten php-4.10 + tomcat 4.0.1 to work together yet?
Thanks.
Vincent Stoessel wrote:
>
> ------------------------------------------------------------------------
>
> Subject:
>
> [PHP] another tomcat 4.01 problem
> From:
>
> Vincent Stoessel <[EMAIL PROTECTED]>
> Date:
>
> Sat, 29 Dec 2001 17:37:26 -0500
> To:
>
> Php General Mailing List <[EMAIL PROTECTED]>
>
> To:
>
> Php General Mailing List <[EMAIL PROTECTED]>
>
>
> I got php4.1.0 sucessfully compiled in and now I get these
> exceptions when I try to run the test php scripts.
>
> java.lang.UnsatisfiedLinkError: send
> at net.php.servlet.send(Native Method)
> at net.php.servlet.service(servlet.java:162)
> at net.php.servlet.service(servlet.java:180)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>
> I know that I am very close now. Any hints?
--
Vincent Stoessel [EMAIL PROTECTED]
Java Linux Apache Mysql Php (JLAMP) Engineer
(301) 362-1750 Mobile (410) 419-8588
AIM, MSN: xaymaca2020 , Yahoo Messenger: vks_jamaica
--- End Message ---