[PHP] need help figuring out how to delete rows?

2003-08-22 Thread Deadsam
Hi Im making a chatroom using flash and php, the one problem Im having is
deleting rows.
What I'm looking for is when they click on the button to send the message
into php-->mySql  it will also
check to see how many rows are in that table and if they are greater then
40, then to delete the rows
over 40, starting with the oldest ones ASC. I thought about using the chatID
number but that will change
everytime. So I was thinking of having it check for how many rows there is
if its greater then 40 rows then
delete thgose over 40 ASC.
Hope I explained it good enough :)
Anyhow if anyone has a solution for this I would really appreciate it.
Thanks in advance
Deadsam




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



Re: [PHP] need help figuring out how to delete rows?

2003-08-26 Thread Deadsam
Cool thanks I'll try it out :)
Deadsam
"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Actualy, it will not. LIMIT can have only one argument with DELETE.
> This will ($count is the number of rows you need to get in a previous
> query):
>
> DELETE FROM table ORDER BY timestamp ASC LIMIT $count-40
>
> Marek Kilimajer wrote:
>
> > DELETE FROM table ORDER BY timestamp DESC LIMIT 40, 1000
> >
> > untested, but should work
> >
> > Deadsam wrote:
> >
> >> Hi Im making a chatroom using flash and php, the one problem Im having
is
> >> deleting rows.
> >> What I'm looking for is when they click on the button to send the
message
> >> into php-->mySql  it will also
> >> check to see how many rows are in that table and if they are greater
then
> >> 40, then to delete the rows
> >> over 40, starting with the oldest ones ASC. I thought about using the
> >> chatID
> >> number but that will change
> >> everytime. So I was thinking of having it check for how many rows
> >> there is
> >> if its greater then 40 rows then
> >> delete thgose over 40 ASC.
> >> Hope I explained it good enough :)
> >> Anyhow if anyone has a solution for this I would really appreciate it.
> >> Thanks in advance
> >> Deadsam
> >>
> >>
> >>
> >>
> >
> >
>

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



[PHP] need help with uploading images

2002-07-28 Thread Deadsam

I'm trying to get an uploader to work, where you check to make sure it's a
jpeg file that's being uploaded, and no other files allowed. the server is
unix linux using php4.1
Any help would be appreciated.
thanks in advance
deasdam



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




Re: [PHP] need help with uploading images

2002-07-28 Thread Deadsam

Thanks oscar I'll give this a go, I tried just using filetype != image/jpeg
so mabey adding the rest will help , I read there was a problem with some
browser with uploading hopfully this will solve the problem.
much apprecatied
Deadsam

"Oscar F" <[EMAIL PROTECTED]> wrote in message
002001c23684$fc68ba20$bc00a8c0@320jupiter">news:002001c23684$fc68ba20$bc00a8c0@320jupiter...
> deadsman,
>
> if (($filename_type != "image/jpeg") && ($filename_type != "image/jpg") &&
> ($filename_type != "image/pjpeg")) {
> header("Location:submitError.php"); exit; //goes to an error page if the
> file wasnt a jpg
> } else {
>  $upload_path = "/path/of/the/$filename_name";
> if (is_uploaded_file($filename)) {
>  Exec("cp $filename $upload_path");
> } else {
>//do whatever if it wasnt uploaded
>   }
>
> The "file" formfield, is called filename.. just in case... if you call it
> myFile, you'd have to replace $filename with that.
>
>  Hope this helps.
>
>Oscar.-
>
> - Original Message -
> From: "Deadsam" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, July 28, 2002 5:53 PM
> Subject: [PHP] need help with uploading images
>
>
> > I'm trying to get an uploader to work, where you check to make sure it's
a
> > jpeg file that's being uploaded, and no other files allowed. the server
is
> > unix linux using php4.1
> > Any help would be appreciated.
> > thanks in advance
> > deasdam
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
>



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




[PHP] Nope it didn't work :(

2002-07-28 Thread Deadsam

I've been trying a few things that should actually work and for some strange
reason they aren't. It's a strange one indeed. jpg is not a MIME type though
(just thought I'd let you know that) but nevertheless it should work, but
for some weird reason it isn't.
I'll keep plugging away at it till I figure it out.
Thanks Anyhow
Deadsam
if you come up with another method please let me know :)

"Oscar F" <[EMAIL PROTECTED]> wrote in message
002001c23684$fc68ba20$bc00a8c0@320jupiter">news:002001c23684$fc68ba20$bc00a8c0@320jupiter...
> deadsman,
>
> if (($filename_type != "image/jpeg") && ($filename_type != "image/jpg") &&
> ($filename_type != "image/pjpeg")) {
> header("Location:submitError.php"); exit; //goes to an error page if the
> file wasnt a jpg
> } else {
>  $upload_path = "/path/of/the/$filename_name";
> if (is_uploaded_file($filename)) {
>  Exec("cp $filename $upload_path");
> } else {
>//do whatever if it wasnt uploaded
>   }
>
> The "file" formfield, is called filename.. just in case... if you call it
> myFile, you'd have to replace $filename with that.
>
>  Hope this helps.
>
>Oscar.-
>
> - Original Message -
> From: "Deadsam" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, July 28, 2002 5:53 PM
> Subject: [PHP] need help with uploading images
>
>
> > I'm trying to get an uploader to work, where you check to make sure it's
a
> > jpeg file that's being uploaded, and no other files allowed. the server
is
> > unix linux using php4.1
> > Any help would be appreciated.
> > thanks in advance
> > deasdam
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
>



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




[PHP] Re: need help with uploading images

2002-07-29 Thread Deadsam

maybe it would be easier to show you the part of code I'm using,

echo $HTTP_POST_FILES['uploadFile']['size'] . "::".
$HTTP_POST_FILES['uploadFile']['name']['type'] . "::";
echo $HTTP_POST_FILES['uploadFile']['name'] . "::".
$HTTP_POST_FILES['uploadFile']['tmp_name'];

*/
?>
http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: need help with uploading images

2002-07-29 Thread Deadsam

This looks good but I just have one question about it if you don't mind,
what if someone was uploading a gif or a PNG file? can it be made to only
detect jpgs?
Thanks in advance
Deadsam

> Try it this way, it will check if it is a jpeg and it has a horizontal
> and vertical size so you can be pretty sure it is an image file.
> (you do not need the gd package for getimagesize())
>
>
> /** Check for the type of the image : only allow jpeg's */
> $im = getimagesize($_FILES['uploadFile');
> if(!($im[2] == 2 && $im[0] > 0 && $im[1] > 0)){
> echo "You can only upload jpg images.";
> exit();
> }
>
>
>
>
> --
> regards,
> Tom
>



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




Re: Re[2]: [PHP] Re: need help with uploading images

2002-07-30 Thread Deadsam

wow I like it :)
thanks alot Tom  you've been a big help and showed me something I never knew
before also at the time
Thanks to all who help me with this , it's very much appreciated
Deadsam


"Tom Rogers" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> Tuesday, July 30, 2002, 1:53:50 PM, you wrote:
> D> This looks good but I just have one question about it if you don't
mind,
> D> what if someone was uploading a gif or a PNG file? can it be made to
only
> D> detect jpgs?
> D> Thanks in advance
> D> Deadsam
>
> >> Try it this way, it will check if it is a jpeg and it has a horizontal
> >> and vertical size so you can be pretty sure it is an image file.
> >> (you do not need the gd package for getimagesize())
> >>
> >>
> >> /** Check for the type of the image : only allow jpeg's */
> >> $im = getimagesize($_FILES['uploadFile');
> >> if(!($im[2] == 2 && $im[0] > 0 && $im[1] > 0)){
> >> echo "You can only upload jpg images.";
> >> exit();
> >> }
>
> The $im[2] being set to 2 means it is a jpeg other image types have a
> different number, have a look at the getimagesize()function for details
>
>
>
>
> --
> regards,
> Tom
>



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




[PHP] need help with a chat code problem

2002-08-29 Thread Deadsam

Im building a chat with php/mySQL but I dont want my database to be filled
up with messages upon messages, what I want to do is make it start deleting
rows after lets say 100 rows (which hold the messages)(each individual row
holds one chat message), is there a way of doing this through deleting the
smallest numberID rows in that table? as each one I want to delete will be
the smallest ID number (as it grows with each message added to it).
If tried to figure this out but so far no luck.
If anyone can help me with this Id greatly appreciate it.
Thanks in advance
Deadsam



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




[PHP] php parsing problem with chat

2002-06-24 Thread Deadsam

Im using a php/flash chat, I added some parsing in it, but now Im having one
problem left to solve, after nickname plus the message (msg) its suppose to
create a new line \n, but if I parse it, and type a link or a swear word
that uses the bad word filtering, it doesnt create a new line after you
press send. It just continues on after you type something in again.I'll add
the script so you can look it over amd let me know if you know where I can
add another \n to make sure it gives me a line break after the parsing.

http://www.flashbuilder.ch
based on the http://www.peopleforfun.com version */
/*Original script by Nicola Delbono <[EMAIL PROTECTED]>*/
/*Modified by Mario http://www.bludocks.com   */
/*Modified by Deadsam at http://www.deadsam.com // added parsing for
links and bad word filter */
?>

", " ", $nickname);
$nickname = stripslashes ($nickname);
?>

&output=
 $max_file_size) {
$lines = file($chat_file);
$a = count($lines);
$u = $a - $chat_lenght;
for($i = $a; $i >= $u ;$i--){
$msg_old =  $lines[$i] . $msg_old;
}
$deleted = unlink($chat_file);
$fp = fopen($chat_file, "a+");
$fw = fwrite($fp, $msg_old);
fclose($fp);
}
$msg = str_replace ("\\","", $message);
//
//IF THE FORGOT TO ADD HTTP:THIS WILL DO IT FOR THEM
$webStart = Array ('WWW', 'www');
$changeWebstart = 'http://www';
$msg = str_replace ($webStart, $changeWebstart, $msg);

//this will take away the double http part
$webDouble = Array ('http://http://www');
$changeWebSingle = 'http://www';
$msg = str_replace ($webDouble, $changeWebSingle, $msg);

// Swear Word Filtering Section
$badwords = Array ("fuck", "shit", "bastard", "fucker", "fucking",  "bitch",
"cunt", "pussy", "dick",);
$changeto = '**';
$msg = str_replace ($badwords, $changeto, $msg);

// EMAIL PARSER
$msg = ereg_replace("[[:alpha:]]+@[^<>[:space:]]+[[:alnum:]]","mailto:\\0\";>\\0", $msg);

//
// URL PARSER FOR MESSAGE
$msg  = ereg_replace ("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]]", "\\0",
$msg);
//$msg = ereg_replace("\[url\]([^\[]+)\[/url\]", "\\1",
$msg);

//
// BOLD, ITALICS, UNDERLINE AND PRE PARSER
$searchFor = Array ('[b]', '[/b]', '[pre]', '[/pre]', '[i]', '[/i]', '[u]',
'[/u]');
$replaceWith = Array ('', '', '', '', '', '',
'', '');
$msg = str_replace ($searchFor, $replaceWith, $msg);

//
// END PARSING SECTION


$msg = stripslashes($msg);
if ($msg != ""){
$fp = fopen($chat_file, "a+");
$fw = fwrite($fp, " $nickname : $msg\n");
fclose($fp);}
$lines = file($chat_file);
$a = count($lines);
$u = $a - $chat_lenght;
for($i = $a; $i >= $u ;$i--){
echo $lines[$i];
}

?>
Thanks in advance for anyone who can help me out
Deadsam



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




[PHP] using cookies and flash problem

2002-05-12 Thread Deadsam

I'm having a problem with using cookies and flash, I'm new to php so it's
more then likely my coding, I have a forum made from flash/php/mysql, and
I'm trying to use cookies for the username and password so they dont have to
log in, I have manage to create the cookies no problem, its the rest thats
wrong, I'll post the code to read the cookies:
 0) {
//Loop through all the cookies...
foreach($HTTP_COOKIE_VARS as $cookieName => $cookieValue){
//output name and value
print "$cookiename=$cookieValue&";
}
} else {
//otherwise out no cookies
print "&userStatus=you are not logged in";
}
?>

In flash I used a loadVariableNum("http://www.deadsam.com/cookiescript.php";,
this, "POST");

I keep getting errors with this.
If anyone has an answer to this I'd appreciate it very much.
Thank you in advance
Deadsam



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