hi theres this box I have to do actually two boxes one with available items and one with selected items and there

when PHP sees a bear word, it thinks you mean a constant. quoting won’t cause errors, so it must be how you’ve written it.

so should we use single or double quotes for array indices ??

you can use either

ok

*technically* single quotes are faster

im trying to recreate the error that was thrown earlier and not finding any success \

But don’t use a bareword, that generates an E_NOTICE and will clash with future keywords
single quotes aren’t faster by enough that you care (probably)

iirc the difference is usually couple ten-hundred-thousandths of a second

besides checkdnsrr is there a way to verify whether the email actually exists or not ??

Nah, you can never be truly sure an email address will exist to be honest

ko

i usually just send the email and check my bounces every so often, heh

s/ko/ok/
im trying to do the same thing, we get tons of bounced emails and im trying to automate the process to delete them from the database

writing a simple script to check an imap mailbox seems to work for me

but how do you checked the bounced email in sendmail using php webhosting ?

There is no way of knowing how valid an email address is, you just have to go with it. You could check the DNS name, but that is dependent on their DNS server working *right now*, which it might not be
And you don’t want to stop someone registering because of a server failure outside of your control and theirs

that is what my script is doing http://pastebin.com/mc0b49aa

they bounce into a predefined IMAP mailbox, and read the box

There are a lot of things wrong with that. Domains don’t need a MX record to be valid for email
Technically, they don’t need to be in DNS at all, your MTA just needs a way of routing messages for that domain, but we’ll ignore that for now
But assuming a public domain, they need a MX *or* an A record
But you should not think someone’s domain is invalid just because its DNS currently doesn’t exist

but usually spam email has non-existant domains

No, it doesn’t. anti spam filter webmail host usually has existing domains

you’re the one spamming.
lol

Most mail servers don’t accept messages from nonexistent domains, so spammers always choose a valid domain. Sometimes they even register domains for the purpose

ok
right now im trying to clean up our db and then create a new subscription model where people have to click on a link in the email web hosting to verify if it exists or not

Personally I’d have the domain checking agent run on cron, and if a Domain hosting is out of DNS every day for, say a week, you can then probably consider it dead
However, almost all of the junk in your db will be from people who have valid domains but invalid mailboxes
One option is to ask all your users to click a link to validate their email address, and any who do not do so, change their status
I’d probably go for that.

isint there any other option beside forcing existing users to click on the link ?.

Just keep the users there, it looks good from a marketing perspective.

Well, you could email them and see whose bounce, but that’s no guarantee that they exist
Some sites don’t send NDRs (non delivery reports)
You can always change the status in your DB to say “unverified” or soemthing, so you don’t include them in subsequent mailshots

yes i wish they wouldnt
I get hundreds as people spam from my addresses

what does ‘fecha’ mean?

NDRs are frequently used by spammers

the problem is that i dont manage the mail server, so i wont be able to get access to all the bounced emails. btw we use sendmail as out mail agent

In which case, ask whoever manages the mail relay to create an alias so the bounces drop into a server that you do manage

for christ sake, just send out a link if clicked = real, if not, mark as ‘inactive’. or, dont delete any of them, so you can tell people you have 10,000 users, instead of 100.

I like that idea

what benefit is there ni cleaning up the user table?
less advertising appeal
less apparent success
lol

thanks

hey anyone know ajax in here? how do I append a button element with an onclick function?

Asynchronous Javascript and XML. I don’t see a PHP in there

i’m not sure what you’re doing is ajax, could be just javascript.
antum *

btw when i use “$row['EMAIL']“; i get “unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE” error

EoN, you could be right there… that should help with my googling
Ramihg, i was just asking… i do know this is the php channel

fail.

use string concatenation instead

Try #javascript that is the right channel

in simpler terms, .

ok

cstextiles, yep just jumped in there, thanks

you might also want to try #prototype

thecoolone19, nice I didn’t know about that one

or #dojo

EoN: I did not knew that there are channels for these also Thanks

Try #javascript that is the right channel, you got the names wrong. hehe

there’s also another one called #jquery
is there a php command to get duplicate colum values of a mysql table ?

I think this is a mysql query. Do you mean all column values of 2 rows being same is duplicate? If Yes then have u made any column a primary key?
The right channel I think is #mysql

no your wrong, the 2 rows are different, only the colums of the rows are the same.

Try Where caluse by “Where fld1=fld2″. Does this satisfy your query?

please ask the question more goodly.

hi, i wondered if there was a library out there for php that took care of user registration processes etc itself, i am making a tool that lets people collaborate in a specific format and i need to put a backend on it, and i assume a kind of user registration system library already
exists

….

pretty much every web app with per user configuration has to take care of the same pattern of registration, authentication, and application-specific data storage, so i assume it has been identified as a frequent pattern and someone has implimented a library to use for it
avoiding reinventing the wheel over and over
but i don’t know much about the php community so i don’t really know how to go about finding said library

look at dem pelicangs fly!

there’s a billion frameworks.
well, at least 10
cakephp, symfony, prado, zend framework, codeigniter, agavi, etc etc
dunno about user specific only. google it.

yeah i googled before irc
but i figured one of you guys would have more specialized knowledge

^_^

hola everyone

hey I have to check if a number is in a couple different ranges, ie. between 20 and 40 it produces result A and between 60 and 80 it produces result B. Any better way to do this other then to just use ifs and elseifs?

Not really. You can use range() but that’s just wasteful

case?
select , case

frankr, like psilo said, you could use if(in_array(range(n1, n2)))…
but it’s much slower than integeral comparisons
probably not noticibly slower, but wasteful, as psilo said

Do it a few million times and you’ll notice :P

yeah, scale matters

As always, context is important to determine what is more important

what’s the name of the function again to reduce the characters on a string?

You can select a part of a string using php.net/substr

ahh thanks~

If you mean something else, please give more info.
np

worst memory tonight :

:O
Cheer up, baby

is there a good howto for uploading zip files (containing images) via php?

it’s just a file, so just upload it as normal
but check the contents of it once extracted

and how do i extract it

http://pecl.php.net/package/zip

thanks

np — first result in my google search

how can i make a mysql_fetch_array to be indexed by number

it already is
mysql_fetch_array = mysql_fetch_row + mysql_fetch_assoc
it’s better to use one or the other if you’re not using both integer indexes and string indexes

k, the thing i wanna do is to first get all the values from a mysql_fetch_array to a array
and then search it with in_array for a value

how do i use the substr function to show the last 20 characters of my string? i’ve tried substr(’string string’, -1 5); with no luck :

php.net/substr
look at example 2456 with the -1 as the second paramater

substr(’string’, 0, 20); ?

*looks for example*

but “string” must be over 20 leters ^^

wait where are the examples numbered?
yeah i’m just trying to do it from the end of the string

it’s better if you can further limit your result set with the sql query

Well if string is less than 20 it would just return the whole string though

actually, it’s proably easier to reverse the string, then do substr( $string, 0, 20 );

i was just thinking that now haha

echo substr(“Returns the portion of string specified by the start and length parameters.”, -20, 20);

since it doesn’t seem to do what i want to do easily
oh hang on
the second parameter is saying where it comes from
the -1 i’ve been using is for the last character

yes

lol why didn’t i tihnk of just basing it on the 20th last character
thanks FinalSoft i didn’t even thinking that

or it:
echo substr(“Returns the portion of string specified by the start and length parameters.”, -20);
more compact

done and done

http://pastebin.com/m81d29dd it only prints out one row, the others are blank

How can I escape only one type of quotes in a string?

\

you’re passing the wrong value to mysql_num_rows: http://www.php.net/mysql_num_rows

$string = “\”hello\”" —would output: “hello”

sorry, nm — you’ve got that right

smokestack, no he’s not

yeah, the variable name threw me off

he needs to iterate mysql_fetch_array in a loop

yep

replace the for with while ($row = mysql_fetch_array($query))
and remove the other $row declaratoin

use mysql_fetch_row instead, for best practices

If I want to put some stuff into a multidim array I can just define it with $multidim = array (); and then start putting things in it $multidim[0]['count'] = 4; right?

DrJ thanks I knew that, let me rephrase. I am looing through 1000’s of strings and some strings are in double quotes and others are in single. I will need to echo the strings like this ’stri\’ng’ or “stri\”ng” or “stri’ng”

there is a add backlashes function
I don’t remember the name of it though

DrJ – I need to somehow replace with a backslash but I can not replace with ”’
addslashes() but that will add slashes to both king of quotes
kind

well mysql_fetch_row does not give an associative array smokestack

hi, there’s this box I have to do, actually two boxes, one with available items and one with selected items, and there should be two buttons in the middle with add item and remove item. Does anyone know what this thing is called ?

so technically you’d use mysql_fetch_assoc for best practices smokestack

Isn’t it quicker not to associate them?
Just get the data by RowID

That’s premature optimization

??

basically the thing i wanna do is to search the output for example, in_array(“car”, $row);

So can someone tell me how I can add slashes to a string without using addslashes – I can not replace with “”"

phtr, you should be using mysql to do that

that’s easily done with #javascri[t
if I can type, #javascript ^^

thanks for the help

AlexC_, ok, thanks

is there a function in pvp to convert a number of seconds, let's say 150 seconds, into mm:ss?

If I want to put some stuff into a multidim array I can just define it with $multidim = array (); and then start putting things in it $multidim[0]['count'] = 4; right?

pvp? php
..

what are you trying to do?
Pixotic-: php.net/date

doesn’t that only deal with unix timestamps?

yes
Pixotic-: what do you think Unix timestamp is

…. DOH
Head, meet desk
*thunk*
Thanks

you’re welcome

I am looing through 1000’s of strings and some strings are in double quotes and others are in single. I will need to echo the strings like this ’stri\’ng’ or “stri\”ng” or “stri’ng”

when im using alter table command, i get “ERROR 1146 (42S02):” even though i did “use mydatabase”
sorry wrong room

with MySQL?
was about to point you to #mysql ^^
so you want them all to ’string’ ?

then why does this return an empty array http://rafb.net/p/zMPFqA88.html
I’m probably making some dumb mistake

AlexC no exactly like outputed

databasequeryreturn just returns a mysql assoc array just like the function does it just connects and closes for me
and I know that part is working b/c I see it prints out that text that I put in the echo there..

do var_dump( $data ); before the return
no,I see the problem!
since when do you do $foo == ‘yay’; to assign a value

.. are you serious
haha
damn
fyke
this is why I should not code at 7 am without sleep on caffeine

I’m looking for an IRC registeration script? (let’s users register with nickserv, without using nickserv?!) …

What is a good way to design your sites structure? I’ve tried MVC and I don’t like it :/

that was terrible ahh

you wont find one here

i want to have the page looking like this http://www.mypage.com/script instead of http://www.mypage.com/?site=script , how can i do that? except creating a dir

#apache and ask about mod_rewrite

that or you could use just a query string.. mypage.com/?script

thanks

$_SERVER["QUERY_STRING"]

btw your URL is wrong. if you are using apache, without redirect you would need to mention the script name before “?”

you don’t have to

that is unless you are calling either index.* page you will have to

www.example.com/?foo=bar will be the same as www.example.com/index.php?foo=bar or what ever your index page is

precisely

there is no need for a redirect, though – thecoolone19

in this case he wants to call script.php file and not index.php so a redirect is necessary

who said he wants script.php?

i want to have the page looking like this http://www.mypage.com/script

yes, that doesn’t mean he wants script.php

So anyone? I am looping though 1000 of strings (from DB) and have two fields one is called STRING and another called QUOTES (which is either the word ’single’ or ‘double’) Now – when iterating over these records I need to print the string with the correct quotes around it AND escape the
correct quotes inside it (only the correct type) So I could get lines like this: “string”, “stri\”ng”, …

…’string’ or ’stri\’ng’ – how can I do this? I can not use str_replace() as replacing “\” is impossible since that just escapes the 2nd quote?

he could want it so that it goes to index.php?site=script – which is what he was using originally, thecoolone19

ok

addcslashes()

I assume you mean addslashes and no – that will not work as it replaces BOTH single and double quotes?

no – I said addcslashes()

Ahh – ok – I will look

if ( $row['quotes'] == ‘double’ ) { $str = addcslashes( $row['string'], “‘” ); } etc
if thats the correct way you want it,

$original_transparency = ($rgb['red'] 16) | ($rgb['green'] 8) | $rgb['blue'];
$rgb is an associative array containing rgb and alpha values

Looks like JUST the thing I needed

i don’t get the ($something number) | (…. stuff

http://uk.php.net/language.operators.bitwise

AlexC_ looking very helpful, thanks!

Hey, anyone know of an easy way to tell precisely how long it takes a script to execute?
other then hitting the refresh button with a stopwatch

how does phpbb enable subscriptions ?? what does it use to encrypt the link it sends to the user to verify the email

frankr, microtime

kthx

microtime(true), even. Annoying little gotcha there

What is a good way to construct your site’s structure? I’ve tried MVC and smarty, and didnt like them..

“tried MVC”?

the MVC idea*

and what didn’t you like about it?
separating view from logic via smarty, another php script or whatever is really a win for maintenance

And how do I set up the ‘logic’?
I didn’t really get the M part, with various frameworks..

yeah I get that feeling too – the model is usually “use a good db abstraction layer”

I tried the Zend Framework, and it wants a model with 4 lines to get info from a table..

mmm, smarty output filters are nice

Alright, I have a interesting one for anyone out there… I have a large single file being fed as a data stream into a PHP script (100MB-4GB) which is then taking this data via a buffer and saving it to file. I need to do a MD5 hash on it. However… saving the file and THEN doing a MD5 hash,
especially when it’s 4GB is very slow, and since I am already sifting through the data, anyone have any idea/way of how to get the MD5 su

helps me boil down these crazy css constructions into custom html tas
tags*

ZF doesn’t force you to use their db abstraction

And where do I use models for then?

I forced myself to use their Zend_Table and friends
but you could use raw pdo or whatever

Do you have a tutorial for it?

there’s the docs on zf site
and #zftalk
there was some tutorial iirc, but I don’t have the link

InsolentDreams, from the md5 spec it seems possible to me.. but I also know that regular encryption algorithms in CFB mode are used when you need to operate on a stream like that
so based on that I’d guess there is something about md5 that makes it not work

when i send a request via fsockopen or curl i get “the parameter is incorrect” error im on win with iis6 and php4.4.0

er, CBC.
I forget

i only get this error with long urls but for short ie http://php.net, it works

I don’t see why it wouldn’t though… all md5 does is take the data and do a calculation of every byte/bit of it based on a stream anyway, mine just happens to need to accumulate over time. :P I don’t want/need to keep all the data in memory just to MD5 the 4GB string, lol. That would be
terrible and sloppy.
And md5′ing the file afterwards seems like such a waste, and takes many additional seconds for no reason.

long url means url http://example.com/blah.php?aa=b&c=%DCFG etc

yeah it does look quite possible, looking at the algorithm now
Well, you know what to do. while ( $buf = fread($s,512) ) { // fun time }}

Well I’m already reading and processing the buffer(s), I have no problems with that.
I have the data in memory already, a part of a large file sequentially, that I want to md5. I’m just annoyed something doesn’t exist in php already.

You will save the file to disk anyway, right

Yes

Hi. How to use Sablotron on PHP5? I see no php5-xslt packages in Debian

PHP trying to keep up with the streaming hash might waste a lot more time than md5()ing at the end..

I installed php5-xsl, but have no idea how to use it
Anyway, I would prefer old known Sablotron instead of this new one

I have semi-infinite (8 processors) processing power but limited (6GB) RAM. This environment/script will be processing many large files simultaneously. I don’t thinking keeping a hash processing in memory per-file is inefficient, even done is PHP, it simply can’t be. Reading a 4gb file would
only be partially cached by the time it was completely done being downloaded and then would have to re-read from the HD instead of from R

Sounds like I need to write a md5 hasher myself in php, which sucks. Any other ideas? :P

hi, there’s this select list without a dropdown menu. does anyone know what it’s called ?

select box with a set height

AlexC_, aitgh, I’ll give it a try, thanks
AlexC_, it’s size, not height, right ?

I guess #html

yea
works with size

look at dem pelicangs fly!

heh
okay this one is a bit of a doozy
(I think)
I have a javascript that functions as a countdown timer
how can I pass the number it outputs each second back to php, so I can format it it?

you can’t

Gah
so let’s say it was counting down from 150 seconds, I would have to format it within the javascript to display as mm:ss?

Pixotic-: #javascript

unless you want to do 150 requests to your webserver to count down a stupid timer

Firstly, I’m already in there. Secondly, I wasn’t asking how to do it in javascript, I as wasking if I would have to do it in javascript

Pixotic-: Probably, yes you’d format your time from JavaScript. How to do that is a question for #web or #javascript.

alright, thank you

You’re welcome.

You can do it via Ajax
But it seems much easier just to format it in Javascript from the start

which will kill your server :P

Ajax would work

I think that’s what TehSausage’s humorous 150 requests was about.

Uhmm I dunno AlexC_
Remember on Gmails page, with the counter that counted up the storage space provided?
I think that was done via Ajax

that’s Google

Lol
Well.. if you have the processing power hehe

they get 1000x more real requests

a countdown timer that does a new AJAX request each second? madness. Times that by how many users are on there

But yeah, definately better to do it client side

= one dead server
or, one wanting to commit suicide server

an emo server

But don’t forget, its only a very small request

considering it’s easier to do a date function in javascript than an xmlhttprequest, why bother? _

it’s a request never the less,

You’d be making a request to your server 150 times over a duration of 150 seconds to display a countdown for a single user. Imagine if it were 2 users, that’s 300 requests for 2 users over a span of 150 seconds, now what if it was 10 users? That’s 1500 requests to your webserver, which then
tells PHP to parse the script 1500 times over a duration of 150 seconds for 10 users.
Now tell me AJAX is NOT an option.

I know I know.. I’ve already said its best to do Javascript
But I was just saying its possible
Of course its an option

an option that will lead to your server hunting you down and killing you in your sleep

Its not the best option, but its an option non the less
Lol
Homicidal server

Stupid options aren’t options

Imagine getting slaughtered by a Celeron… The embarrasement

possible, though

I’ve already said that Google have done it

I doubt it

And the way I see it, Google pionier web usage a lot
You know Google are Ajax crazy don’t you? :p

google did it via JS too

i dont think that space counter was ajax =\

I must go, food o’clock and F1 – can’t get better than that

Ajax is Javascript

maybe there was an ajax re-sync every so often

Using AJAX properly is obviously different from using it improperly

Enjoy

but the counter was simply js

it probably wasnt even accurate if you left the page open for afew hours

^^ will do, cya

byez

you’re forgetting another thing – lag would sometimes cause *formatting a number* to take several seconds

AJAX isn’t JavaScript. XMLHttpRequest is JavaScript.

Several seconds? No but it would definately cause an unneeded delay

not everyone is on a 100Mbit line next to your server
and a saturated ADSL is well… laggy.

You talking of 10 bytes a second… per user
Thats not a massive amount
10 bytes + headers :p

10 bytes, plus a new tcp connection
and apache/php load times

that’s not counting TCP, IP overhead, and the HTTP headers which are no doubt much more than 10 bytes

even if it’s jus a single packet

and yeah, a new connection each time too

it can *still* take several seconds sometimes

does xmlhttprequest use keep-alive?
that would make it slightly more reasonalble, but still stupid

I’m sure the google storage space counter was ‘faked’

Is there a way to delay the execution of a php script from within php itself? e.g. have it exec 30 seconds after the current script is run

They told the js how quickly to run the counter and let it run blindly.

I made some changes to my php.ini, and now all .php pages just display the source. Where can I see what is wrong?

no doubt… at best, it probably computes an average rate gain value at page load time and sends that out, … yeah.

Yep
I’m perusing the GD manual right now.. don’t see anything about slicing and dicing an image. Will I be able to do this?
I want to make four 50×50 gifs out of a 100×100

I haven’t worked with it in a while, but there should be functions that let you copy parts of one image into another

like.. imagecopy? XD

e.g. create a 50×50 image object and copy from (0,0)-(49,49) of the source image

Ah copy, cool. I wasn’t thinking of it in those terms
That makes sense though

*looks* yeah, imagecopy will do that

*
To prove that you're not a bot, enter this code
Anti-Spam Image

Comments are closed.