php-general Digest 25 Apr 2005 07:17:01 -0000 Issue 3417
Topics (messages 213759 through 213774):
Can not insert local language into db
213759 by: JohnyG
Re: htaccess file
213760 by: Jochem Maas
Re: I need do paging in php, I use ODBC Access
213761 by: Jochem Maas
Re: From form to db question
213762 by: Richard Lynch
Re: Error Handler
213763 by: Richard Lynch
Re: help for me about session
213764 by: Richard Lynch
Re: Strange problem with picture Upload
213765 by: Richard Lynch
213766 by: Richard Lynch
Re: �ظ�:Re: [PHP] about session
213767 by: Richard Lynch
Re: paste part of mp3 to over an mp3
213768 by: Richard Lynch
Re: Tesing Gzip files
213769 by: Richard Lynch
Re: Is it possible to save a file with UTF-8 encoding and no BOM using PHP?
213770 by: Richard Lynch
Re: Re:Re: [PHP] help for me about session
213771 by: Warren Vail
help with install to one page only
213772 by: Lisa A
213773 by: Drewcore
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result
resource
213774 by: Mark Sargent
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 ---
Hi,
I installed phpbb forum application on commercial server (brinkster.com)
with mySql as database.
You can see the application here:
http://www.adeo.co.il/forum/
When i try to insert English characters everythink works fine
but when i try to insert Hebrew (my local language) characters
weird signs appear (you can see in the link above).
When i look inside the Db the hebrew data is also seen as weird characters.
What might cause this?
doesn't php and mySql use unicode?
How can i fix this?
--- End Message ---
--- Begin Message ---
Greg Donald wrote:
On 4/21/05, Pieter du Toit <[EMAIL PROTECTED]> wrote:
Is there any way that i can see if using htaccess file is enabled on server
without contacting my isp.
I created a htaccess file and ftp'd it to the server with the
register_globals flag set to 0:
php_admin_flag register_globals 0
php_flag register_globals Off
is what I've always used.
On/Off and 0/1 are interchangeable in this context.
but what really got me was the line:
php_flag engine off
that pretty much take away any doubt that this might have been a php related question :-)
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
On Fri, April 22, 2005 7:31 am, Matthew Weier O'Phinney said:
Actually, LIMIT is in ANSI SQL.
Either the ANSI standard changed, or Rasmus needs to update his Bio...
http://lerdorf.com/bio.php
"...he can be blamed for the ANSI92 SQL-defying LIMIT clause in mSQL 1.x
which has now, at least conceptually, crept into both MySQL and
PostgreSQL."
I stand corrected (twice), apologies to Rasmus.
But, hey, I'm not gonna actually READ the ANSI standard to find out -- I'd
rather worry about what actually *WORKS* than what the SQL standard is,
which, sadly, is seldom easily reconciled with Real-Life (tm).
with you there :-)
--- End Message ---
--- Begin Message ---
On Sun, April 24, 2005 3:26 am, William Stokes said:
> I writing a script that allows user to update a soccer league table with
> web
> form. I made a script that prints the old values to text fields in the
> form.
> It's done with a loop so that each text field name is numbered +1 higher
> than previous.
Change the NAME to something like:
NAME="new_games[$i]"
where $i goes from 1 to 14.
That way, you'll have an array called $new_games to work with.
Then you can use a for loop like:
$new_games = $_POST['new_games'];
while (list($i, $value) = each($new_games)){
$query = "update x_series set games = '$value' where name = '$team$i'";
}
Sending 14 queries is no big deal... But you wouldn't want to do like,
100...
This is actually answered in the FAQ.
http://php.net/faq.php
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sun, April 24, 2005 12:58 am, Pinoy Ako said:
> Noong 06:24 AM 4/23/2005, Ang sabi ni Richard Lynch...
>
>>Is an undefined function one of the examples? If not, try one of those.
>
> I use the examples given in the example and it works but I'm not after
> errors inside a function. I'm trying to see, what if I forgot to create a
> function or what if I mistyped a function, then it should trigger a fatal
> error using the custom error handler.
Perhaps it "should" but I don't think it "does"
Search the bugs database for more info.
http://bugs.php.net/
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sat, April 23, 2005 7:35 pm, Josephson Tracy said:
> hi everyone,
> when i study php, i have a problem as following:
> ---------------------
> file1.php
> <?
> if($NextCourse == 1){ do something;}
> else($NextCourse ==""){do something other }
> ?>
>
> <script language="javascript">
> function hasNextCourse(){
> document.form1.NextCourse.value = 1;
alert('Setting NextCourse to 1');
> }
> </script>
>
>
> <form name="form1" method="post" action="file1.php" onSubmit="return
> checkform()">
> <input type="hidden" name="NextCourse">
> <input type="submit" name="Submit32" value="next" onClick=" return
> hasNextCourse()">
> </form>
> -------------------------
> but when the 2ed access the file1.php
> the value of $NextCourse is the $NextCourse in the <? and ?>, Not the
There is no value give to it initially, so I'm not quite sure what you
mean...
If you have register_globals OFF, it might appear to never get set to 1,
because it's in $_POST['NextCourse'] not in $NextCourse
Your else() above isn't valud syntax...
Perhaps you should post EXACTLY what your code looks like...
> value of document.form1.NextCourse.value.
>
> could someone tell me why?thanks
This could probably be done easier, by the way, by just using:
<input type="submit" name="NextCourse" value="Click me if there is another">
and then:
<?php
if (isset($_POST['NextCourse'])){
//They clicked the button to indicate another
}
else{
//They clicked some other button
}
?>
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sat, April 23, 2005 7:44 am, Labunski said:
> Hi guys,
> I have to say, I've written so many scripts that had file upload functions
> included,
> but this time something strange is happening.
>
> The script passes the IMAGE_TYPE check, and picture's name stores in the
> database (so I guess the picture should have been stored in the dir.), but
> when I look at the ftp - there's no picture in the upload directory.
I suspect your test for JPEG||GIF is messing up, and the file is getting
deleted because of that.
Try adding the line below and see what it does.
> Chmod of the directory is 777;
>
> Here it is:
>
> $realdir = $_SERVER['DOCUMENT_ROOT'].'/img/';
> $uploadfile = $realdir. basename($_FILES['postbilde']['name']);
>
> if (move_uploaded_file($_FILES['postbilde']['tmp_name'],
> $uploadfile)) {
> $put_name_en = $_POST['subject_en'];
>
> if (!empty($put_name_en)) {
> $image = basename($_FILES['postbilde']['name']);
> $check_image =
> $_SERVER['DOCUMENT_ROOT'].'/img/'.$image;
>
> if( (exif_imagetype("$check_image") ==
> IMAGETYPE_JPEG)||(exif_imagetype("$check_image") == IMAGETYPE_GIF) ){
> $put_img = $image;
> }else{
> $img_root = $_SERVER['DOCUMENT_ROOT'].'/img/';
> $kick = $img_root.$image;
> unlink($kick);
echo "INVALID IMAGE: That file looks like neither JPEG nor GIF<br />\n";
> $put_img = '';
> }
>
> mysql_query("INSERT INTO data (subject_en, img)
> VALUES ('$put_name_en', '$put_img')") OR die(mysql_error());
>
> echo '<META HTTP-EQUIV="Refresh"
> CONTENT="0;URL=update.php">';
> }
> } else {
> echo "The upload was unsuccessful !";
> }
>
>
> Sorry for my bad english,
> Thank you in advance,
> Lab.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
PS You are inserting the image info into the database even if it's not a
valid JPEG or GIF and you are throwing it out -- That's probably NOT what
you really want to do anyway. So even if that's not what is wrong in this
case, your logic is a bit "off" in that part.
On Sat, April 23, 2005 7:44 am, Labunski said:
> Hi guys,
> I have to say, I've written so many scripts that had file upload functions
> included,
> but this time something strange is happening.
>
> The script passes the IMAGE_TYPE check, and picture's name stores in the
> database (so I guess the picture should have been stored in the dir.), but
> when I look at the ftp - there's no picture in the upload directory.
>
> Chmod of the directory is 777;
>
> Here it is:
>
> $realdir = $_SERVER['DOCUMENT_ROOT'].'/img/';
> $uploadfile = $realdir. basename($_FILES['postbilde']['name']);
>
> if (move_uploaded_file($_FILES['postbilde']['tmp_name'],
> $uploadfile)) {
> $put_name_en = $_POST['subject_en'];
>
> if (!empty($put_name_en)) {
> $image = basename($_FILES['postbilde']['name']);
> $check_image =
> $_SERVER['DOCUMENT_ROOT'].'/img/'.$image;
>
> if( (exif_imagetype("$check_image") ==
> IMAGETYPE_JPEG)||(exif_imagetype("$check_image") == IMAGETYPE_GIF) ){
> $put_img = $image;
> }else{
> $img_root = $_SERVER['DOCUMENT_ROOT'].'/img/';
> $kick = $img_root.$image;
> unlink($kick);
> $put_img = '';
> }
>
> mysql_query("INSERT INTO data (subject_en, img)
> VALUES ('$put_name_en', '$put_img')") OR die(mysql_error());
>
> echo '<META HTTP-EQUIV="Refresh"
> CONTENT="0;URL=update.php">';
> }
> } else {
> echo "The upload was unsuccessful !";
> }
>
>
> Sorry for my bad english,
> Thank you in advance,
> Lab.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sat, April 23, 2005 4:06 am, [EMAIL PROTECTED] said:
> that 's say I must session_register at fitst ,and use $_SESSION['time'] at
> secoend?
In theory, these two are the same:
<?php
session_register('time');
$foo = time();
?>
<?php
$_SESSION['time'] = time();
?>
However, the session_regsiter is the "old way" and is deprecated.
So, don't do that in any new code you write.
Or, to think of it another way, just doing $_SESSION['foo'] = 42; will
automatically 'register' the variable/value in your session data for you
and give it a value all in one step.
It's much more convenient than the "old way"
> and How can i get the value of the form's element?
A form's element has *NOTHING* to do with a $_SESSION variable, unless YOU
decide to make them interact.
You get FORM elements with $_POST.
Example:
<?php
if (isset($_POST['foo'])){
echo "foo is $_POST[foo]<hr />\n";
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<input name="foo" value="bar"><br />
<input type="submit" value="Click Me!">
</form>
> just use $time ?
If you want read the FORM data, use $_POST['time'];
If you want read/write the SESSION data, use $_SESSION['time'];
You might want to take the 'time' put in by the user in a FORM on one
page, and store it in a SESSION so you have it on later pages, and then,
eventually, you will put it in your database.
On the SECOND page, after they hit submit on the FORM page, you would have
this:
<?php
$_SESSION['time'] = $_FORM['time'];
?>
You would then use something like this, later, when you put it in the
database:
<?php
$time = $_SESSION['time'];
$query = "insert into ... (time, ...) values('$time', ...)";
?>
You would also want to make sure that the $time provided by the user was
REASONABLE and not an SQL Injection attack. Google for "sql injection"
for more info about that.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sat, April 23, 2005 3:16 am, QT said:
> Do you know any classes to paste some part of mp3 to over another mp3?
http://www.getid3.org/
In addition to making it possible to add ID3 meta tags such as artist,
album, copyright, etc, I'm pretty sure it will let you combine MP3s in
various ways.
If not, almost for sure the folks who hang out in that forum can point you
in the right direction.
PS I use getID3 to dynamically add ID3 info from my database to MP3s --
This allows artists to update their song titles etc at any time, and the
MP3s do not need to be re-generated or re-encoded. Pretty nifty.
http://uncommonground.com/
NOTE: Many players won't show ID3 tags from streaming audio, so you have
to download an MP3 to see them :-(
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sat, April 23, 2005 12:44 am, Prathaban Mookiah said:
> Is there a way to test if a .gz file is in a valid format. Functions like
> gzread, gzfile don't seem to care if the file is corrupt or not.
>
> gzeof also didn't work for me. I guess it is because it does not check for
> a
> valid .gz termination. Any ideas to go about doing this?
Google for gz and gzip and validity tests.
Most likely, you'll need to http://php.net/exec to test the files...
Or you could maybe add in the functionality to PHP itself with some C
hacking :-)
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Fri, April 22, 2005 9:54 pm, Rasmus Lerdorf said:
>>>Maybe I'm just being dumb, but I think if you UTF-8 encode your data,
>>> and
>>>http://php.net/fwrite it, you're gonna get what you want...
>>>
>>>Dunno about the Byte-Order-Mark part, but I guess you could strip it out
>>>of the UTF-8 encoded data before writing, if you wanted to.
>>
>> That was the first thing I tried, and it doesn't seem to work (it always
>> saves in windows default encoding). Unless I missing something about
>> what
>> you can do with fwrite. Did you actually test that before you replied,
>> and
>> found that it would? If so, how? The Byte Order Mark is a part of the
>> binary
>> file that is written, how would one go about stripping it out??
I didn't try anything.
I wouldn't know a UTF-8 it it walked up and bit me on the ass. :-)
But I *do* know that PHP's fwrite is much too low-level to be doing
encoding types and whatnot.
It just writes whatever you tell it.
If you think it's always saving in windows default encoding, perhaps your
test is not distinguishing between having no BOM (whatever that is) and
having the Windows BOM or whatever makes you think it's Windows format.
As far as getting rid of the BOM, assuming you've got your UTF-8 string
thingie, and you know where the BOM occurs, you'd just use
http://php.net/substr on it, I reckon...
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Looks like you are mixing JavaScript syntax with PHP, and that doesn't
work since JavaScript runs on the browser machine, and PHP on the server
(document.form.NextCourse.value is a syntax you will find in JavaScript,
not PHP).
Try something like this;
<?php
Startsession();
If($_SESSION["NextCourse"] == 1) {
do something here on 2nd pass
} else {
do something here on 1st pass
$_SESSION["NextCourse"] = 1;
}
?>
Make sure sessions are enabled on your server, you can confirm this by
executing php_info();
HTH,
Warren Vail
> -----Original Message-----
> From: Josephson Tracy [mailto:[EMAIL PROTECTED]
> Sent: Sunday, April 24, 2005 8:27 AM
> To: Steve Buehler
> Cc: php-mailing-lists
> Subject: Re: [PHP] Re:Re: [PHP] help for me about session
>
>
> I want to get the value of document.form1.NextCourse.value
> But I got the value of $NextCourse in last page.
>
> Steve Buehler <[EMAIL PROTECTED]> wrote:
>
> At 10:29 PM 4/23/2005, Josephson Tracy wrote:
> > > At 09:35 PM 4/23/2005, Josephson Tracy wrote:
> > > >hi everyone,
> > > >when i study php, i have a problem as following:
> > > >---------------------
> > > >file1.php
> > > >> > >if($NextCourse == 1){ do something;}
> > > >else($NextCourse ==""){do something other }
> > > >?>
> > > >-------------------------
> > > >but when the 2ed access the file1.php
> > > >the value of $NextCourse is the $NextCourse in the , Not
> the value
> > > >of document.form1.NextCourse.value.
> > > >
> > > >could someone tell me why?thanks
> > >
> > > I believe it should be:
> > > > > if($NextCourse == 1){ do something; }
> > > elseif(!$NextCourse){ do something other; }
> > > > >
> > > By the way you have your statement, I think you are only
> looking for
> > > the "1". You might try the following instead.
> > > > > if($NextCourse == 1){
> > > do something;
> > > }else{
> > > do something else;
> > > }
> > > ?>
> > >
> >ok. the key problem is when I click the button to submit.
> >the value of $NextCourse is not the value of value
> > of document.form1.NextCourse.value.
> >just is the pre page's $NextCourse,that's say "null";
> >how can i get document.form1.NextCourse.value?
>
> How are you passing the variable $NextCourse to this script?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
--- End Message ---
--- Begin Message ---
I need help with this please.
I've just got a calendar script that was simple to upload the files. I was
told to just add this code into the page ( I want the calendar to go:
d)Add the following lines in the file where you want HEC (Event Calendar) to
be displayed
<?php
include "./HEC/calendar.php";
?>
Note: Your file should be present in the same folder where HEC/ is present
E.g:
~/testcal.php [your file where you want to display event calendar]
~/HEC/**** [unzipped HEC package]
( I made a page called testcalendar.php and put it in the foldeer HEC, but I
am getting error messages.
Warning: main(./HEC/calendar.php): failed to open stream: No such file or
directory in /home/webscape/public_html/HEC/testcalendar.php on line 50
Warning: main(./HEC/calendar.php): failed to open stream: No such file or
directory in /home/webscape/public_html/HEC/testcalendar.php on line 50
Warning: main(): Failed opening './HEC/calendar.php' for inclusion
(include_path='.:/usr/lib/php:/usr/local/lib/php') in
/home/webscape/public_html/HEC/testcalendar.php on line 50
thanks to anyone that can help me.
--- End Message ---
--- Begin Message ---
lisa,
i think your problem may be simple enough... but if this doesn't work,
i dunno... i'm guessing that you're using some webhost right? well...
> Note: Your file should be present in the same folder where HEC/ is present
> E.g:
> ~/testcal.php [your file where you want to display event calendar]
> ~/HEC/**** [unzipped HEC package]
>
> ( I made a page called testcalendar.php and put it in the foldeer HEC, but I
> am getting error messages.
okay.. you put your file (testcalendar.php) in the HEC folder, but
you're supposed to put it in the same folder as the HEC folder...
using windows, the path would look like this:
c:\folder\subfolder\testcalendar.php
c:\folder\subfolder\HEC\
but http addresses are written in unix style, so it looks like this
/folder/subfolder/testcalendar.php
/folder/subfolder/HEC/
hope that makes a little more sense to you... just move that file up
one directory and try running it again.
drew
--
dc .. drewcore.com
--- End Message ---
--- Begin Message ---
Hi All,
get the following error when calling data from mysql,
*Warning*: mysql_fetch_row(): supplied argument is not a valid MySQL
result resource in */var/www/html/phpmysqltable.php* on line *36
*
Below are snippets of my code,
Line 22: $result = mysql_query("SELECT product_name,
product_model_number, product_serial_number FROM Products",$db);
Line 36: while ($myrow = mysql_fetch_row($result)) {
printf("<tr><td>%s %s</td><td>%s</td><td>%s
%</td></tr>\n",
$myrow[1], $myrow[2], $myrow[3]);
I'm following a webmonkey.com tut for php/mysql.
http://webmonkey.wired.com/webmonkey/99/21/index3a.html
Cheers.
Mark Sargent.
--- End Message ---