If I use a MySQL query and then do whiledata = mysql_fetch_assocqueryresult {} I can loop through the dat doing

i'm saying you can treat '1' as a pointer, if you want (you'd just better hope it points to the thing you're de-referencing)

you can treat it as whatever you want

yes, char * for the loose

C lets you
that's the "shoot yoruself in the foot" part you know

that's what i'm saying

Only with explicit casting.

Jerrik, no

in C '1' == (int)49

also without
that's the "shoot yoruself in the foot" part you know

C doesn't require explicit casting
C++ does

C++ sucks too
it tries to help you think
bad thing

ZOMG!!@! LANGAUGE TROLLING!!

noimnot so which language do you use

therefore make you want to think less, therefore produces more errors than needed

and "C" == you don't wanna know - it's a pointer

C if i have a say

That's an array.
lol

ok - be perfect

it's just a bunch of quantum states

are $_GET,$_POST,$_SERVER vars always global or i must global; them too
?

they are super global

cool, thanks

they are always in your scope

excellent

in your scope, containing unescaped user input

hello everyone i have a function that i want to make as a select box
anyone mind helping me with the code

I'll bite… sure

hi i have small problem please look at the code http://php.pastebin.com/m7d14dc51

pear.php.net/html_quickform

http://paste2.org/p/5695

Hi ##php

deepbluegene, what's with all the \t's?

hmm…are you sure about this f00li5h?

about what now?

deepbluegene, that paste is just horribe, don't expect much help with that

Initialize $c as select

oh yes sorry

f00li5h, about $_GET and $_POST being super global

yes, i'm sure.

hey

may be problem with pastebin or i do not know how to paste .what should i do.please suggest.what should i post

screw it, its break time

I want to setup a vpn server that windows xp users can connect to, and it needs to support more than 1 connection unlike windows xp, any of you experienced with them yet

php.net/language.variables.predefined

f00li5h, am getting reports …

deepbluegene, where is line 47?

what does that even mean?

deepbluegene, also part of your problem is css related; this is #php

var_export($_POST); # will work in any scope

j@(931(&$@!#!!++h!!x and other stuff, how can I "filter" such erroneous symbols and characters out of a string?

i have a class and wanna use $_GET inside it, however i get error that its not defined

I think php has is_alpha

stealth preg_match?

lies.

whoops wrong channel

ctype_alpha()

how i can set id in php host when i make a list.that is the problem i am facing.please help.i want to set id and then change its properties in css

specifically php.net/manual/en/reserved.variables.php#reserved.variables.get

hum

deepbluegene, id of what? please try to explain; i am not a mindreader

thank you very much!

liek this jerrik?
http://paste2.org/p/5696

Looks good.

hum its still not working on my file

Oh. Return $c, not $name

i want to output a list from array elements i want to set id for the list and then change color and size of list items.

oh lol

deepbluegene, i think you are confusing server hosting side with client side
deepbluegene, dunno what you want

noimnot:ok .thanx for reply.i will try again to clearly explain the problem.thanx again

deepbluegene, np, try proper english tho :P

I think you're trying to do something similar to LookAgain79, check out the pastebins he just posted (though, it uses a db result instead of an array)

noimnot:Thank you
jerrik:solved the problem.

its not showing the names though
i have a select box finally thought yahoo

Oh

its supposed to be pulling fro mthe e107_users table
and pulling user_name

When you're using variables in a "" string, Using say "Blah $lala" works fine, but if you're trying to use an array, you must use {}'s around it. Eg. "Blah {$name['user_name']} sux!"

I got a problem trying to execute a program with exec and sudo. The user apache is in /etc/sudoers

jerrik:i separated html and php and now it is working fine as intended

It returns 1

? ok you lost me there

Uhh
$c.="option value='$name' align='left'$name[user_name]/option";

oh lol

You want to change $name[user_name] to {$name['user_name']}

sorry im not the best coder in the world im a novie actually

Me too!

When in an interpolated string, you can also simply leave off the quotes
echo "$some_array[some_key]';

Ahh. Cool
Wow… that's pretty handy

Exists any problem to run a program with exec function and sudo, if the apache user is in /etc/sudoers. Because it retuns me 1 and no 0.

undo that sudoers entry instantly - and find a different way - without root access - you may escape hell doing so

apache ALL = (ALL) NOPASSWD: /sbin/cbq.init,/sbin/tc,/sbin/ip

i think im not pulling the names right i guess
guess its still not working right
i thinkits not pulling the info right

how deep is the continue; scope

Im tring to run using php a program using sudo, I have this line in my /etc/sudoers apache ALL = (ALL) NOPASSWD: /sbin/cbq.init,/sbin/tc,/sbin/ip but PHP returns me 1 and not 0. I verify that the user in my httpd.conf is "apache", any idea?

sorry
i dont know how that got highlighted like that
testing
cool awesome
lol

whats the name of the php config file? I did a 'find / -name php.conf' and it doesn't return anything..I need to enable php's file upload function (or at least see if thats the problem, $result is empty when I try to upload a file)

php.ini
RTFM!
sorry had to say it. it felt good.

lol

hey guys

doh
thanks

When im setting $CFG['news_forum'] = '1'; for portals how do i know what ids are which? Does it go down starting numerically?

what the heck are you talking about?

I think he's using a forum portal and asking us questions specific to that forum.

apache is in /etc/sudoers+6+6+6++6
——635365365258588585++++-+6+++++++++++++++41

nvm i got it

any ideas why would $_POST be set on firefox but now when i use IE?

yes
submitting the form by pressing "enter" versus clicking the submit button

umm, i have input type="image"…

Hi all

no, I'm serious!
s/button/image/ then :P

but i want image…

then do the image in CSS

I forget which is which, but one of the browsers does or doesn't set the value of the submit element when it's clicked or enter is pressed

and use a normal button

I think it's IE *doesn't* set the value of the submit element in $_POST if you *don't* click on the submit button/image/whatever

Can I use the Sendmail_From with Linux? I see it only lists Windows as an option. What are my other options to get mail() to allow me to set the From: header correctly?

i.e., you post the form by pressing enter

ppl
is it possible to set a SESSION or POST variable when i click a link?

i click on submit IMAGE…

If I use a MySQL query and then do while($data = mysql_fetch_assoc($queryresult)) {} I can loop through the dat doing whatever I want with it. B ut if I want to do the same, but ude one loop for two different sets of data, then I do $data = mysql_fetch_assoc($queryresult) then $data2 =
mysql_fetch_assoc($queryresult2) then I do $data3 = $data + $data2 to get my master array… Then what do I put in the while() to loop through that data?

http://www.thefutureoftheweb.com/blog/submit-a-form-in-ie-with-enter

with javascript, yes

just JS ajnewbold ?

pretty sure, yeah

isn't there a straightforward way?

I wish, but no

just with forms?

Easiest would be to build a query that joins the datasets on the database

forms, sure, but you can't submit a form with a plain text link

But, failing that, use a foreach() loop instead of a while() loop

is it a bad habit to have lots of forms in a doc?

thing?

it's a bad habit to have any more forms than you need

I was trying to do this, but I'm nto sure how, I was going to just do SELECT * FROM table1, table2, but for each one there is a different set of requirements for WHERE

yeah, generally that suggests that you're not thinking things through properly :P

well, i want to delete articles but i dont want to pass the variables through URL
maybe setting a session variable

this sucks so much
so much that it hurts…

Assuming table1 and table2 share a key in common: select * from table1, table2 where table1.shared_key = table2.shared_key
#mysql can almost certainly help you in more detail

that only let an article to be deleted if isset
what do you think ajnewbold ?

i googled for a little bit but so far no luck. is there a opensource php code that will take obfuscated (or, actually, simply unformatted) html and output it in nicely formatted and indented. i need not highlighting. thanks

ah, so you have a security issue?
you want to prevent accidental deletion of something?

yeah

I had a go, problem is they really don't have anything in common, it's completely different data, but it just so happens that I need to do the same thing with both sets

Having delete and similar actions, called "non-idempotent" by the RFCs, simply by clicking on a link isn't usually a good thing to do

only if the user has reached the last page he can use the next to delete

Anyone have anything to parse ctags output?

i think it is secure enough

There are too many pieces of software that will attempt to "pre-fetch" data by clicking all the links in a given document

just have the script be aware of the page the user is on, and only allow deletion if $page == $last_page

exactly

I'll use foreach(), thanks

if($_SESSION['passcode_to_delete'] == 'something_confusing_to_know_one_know') { delete article}
what do ya think ajnewbold ?
secure enough?

sure

thanks ajnewbold ;=

if you're worried..
don't actually "delete" anything
just mark it as "deleted" which really means "hidden"

I'm not sure I understand the manual entry for foreach…

so you can always go back and "unhide/undelete" it

the something_confusing_to_know_one_know is just to be sure no one uses another $last_page in other server and makes a connection to the delete one using the proper malicious input
well, that's not a bad idea at all
maybe ill make a temp folder for deleted itens, as they are articles
in CSV files

The way I think of arrays is like tables, well my table has two columns, 'name' and 'content' and I need to use both these in the loop… How do I do this? As far as I can understand, foreach takes all the values of the array and lets you manipulate them all in the same way…?

they do not depend on dates of insertion, so maybe that's a pretty cool way of doing it
no ajnewbold ?

sure, that sounds god
good*

thanks a lot ajnewbold
well, gonna craft it

have fun :

thanks m8s

hey

foreach($array as $item) { do stuff with $item }
Just like while($item = mysql_fetch_array($foo)) { $item }

Oh ok, so it just makes an array, except instead of it being called $array it's called $item?

No, it iterates through an array

you cant use any state of the session - use only $_POST or $_GET (maybe with hidden fields) to determin what to do - in addition you may wanna do some locking in the database

I see, in my array I ahve name and content, so I can still use $item['name'] and $item['content'] right?

michlemken could you be more generalist please?

yes

i did not understand quite well
excuse me my ignorance

Thanks, I'll give it a go

gn8

it's client server - nothing else - the client ask things, the server bounces back information - at the point the client provides ALL information you may do an action
it's client server - nothing else - the client ask things, the server bounces back information - at the point the client provides ALL information you may do an action

how can i match a string against an array? I need to see if any words in a string match any word in an array

vls michlemken ?
j2daosh

yes?

maybe transforming the string in an array
by using spaces as divisions to make an array with words
then comparing the diverse array elements
no?

ok, then how would i check a word against every element of an array?

i think so
but i dunno if it is very performance-wise to do it
maybe there is a better choice
for the first step you can use this
http://pt.php.net/explode
then you can use a foreach($first_array as $value { foreach ($second_array as $value2) { if ($value1==value2) {return true;}}}
no?
does this even works? :P

i have no idea what that code even means

it that has been well written, then for each array element it would test if it is equal to each of the other elements
j2daosh have u made something in PHP?

yeah but i have never used a foreach conditional or the "return" function

in_array() or array_search would be much better

well, foreach is a loop, not a conditional, and return is a statement, not a function

McFly maybe
somethings i never used i dont ever thought about it
yeah, j2daosh, use in_array

yeah i was looking at both he mentioned and in_array seems exactly like what i am looking for.

first use the explode to split the string
then use the foreach on the newly created array and inside put the in_array function

If I've got two arrays ($data2 and $data3) which are made from mysql_fetch_assoc() what's wrong with putting $data4 = $data2 + $data3; ?
I get a message saying invalid operand and I have no idea what that means

hi
can anyone help me with getting php 5.2.3 installed and working on apache 2.0
on windows

Just install WAMP
let it do the heavy lifting for you

whats wamp?

It's just what you need
http://www.wampserver.com/en/

is it easy to use, i'm new

Absolutely.
It's Apache, PHP, and mysql for Windows
All in one neat bundle

Right, I've got to go all, off on vacation so talk int wo weeks, tata

use $data4 = array_merge($data2,$data3);

was just going to ask that

dang too late
lol

^Hyperion: The installer handles all configuration for you

what if I don't need mysql?
can i choose not to install it?

^Hyperion: There may be an option to exclude it, I forget

you may use your search key as a key for the array values in the first place - then array_key_exists($key, $array)

It's a pretty flexible thing

i'll try it thanks

i need to learn how to do a foreach with php

what do you want to loop through?

i made an array of blocked words for my guestbook and i exploded the user comments and now i have to understand the foreach loop so i can do a match thru the comment for any blocked words
ok, i think i understand vaguely the foreach… god i love simple examples

str_replace() will accept an array
so technically you can replace all of the "bad" words in one swoop
without using a loop

but i dont want to replace. I want to check if a bad word exists and then tell the user that the word exists and can't post comment until its changed

ah
yeah, you want a loop then

that function will come in handy though. thank you for mentioning it

no problem

what a task - please be correct for all languages in the internet

lol well i doubt i will have many non-english users visiting my site… but if i do, ill look into all the "bad words" in that language

generally speaking, filters aren't very effective
people always find creative ways to break them
I've seen it all

yeah but most (if not all) of the people that sign my guestbook, aren't going to be trying to put cuss words in. they will just get the error saying that the language isn't approriate and that they should change it. I have faith in people :P

the kind of people who are going to use foul language in the first place are the kind of people who are going to try to get around your filter :P

Just wondering.. is there a simple way to use a wildcard in php.. I'm trying to filter out files that have 'thumb' in them.. I've managed to filter specific out filenames, but I'm wanting to do something like 'thumb*' with * being a wildcard for a whole directory of files..

true, true… but i work nights and have nothing better to do then delete comments lol
btrue, true… but i work nights and have nothing better to do then delete comments lol/b
it might even make my night go by quicker lol

what's your url?

lol

you are trying censorship - and you will be always behind - or blank out too much - like an ordinary 'fuck you' (NOT you !)

no cussing for you dang it

no, I won't
I was just curious to see what you're working on

i have an index page that i'd like to allow users to rearrange "modules" on, and have it saved in the database?
er wow incomplete question

oh well its kinda… well not finished and ugly presently

what would be the best web hosting way about doing that?

with wamp, does it have fsockopen?

that's cool you just learn php recently?
^Hyperion: it's got everything

or can I use it? how

^Hyperion: same way you'd use it anywhere else

i have a script that worked on my online host but isn't working with this

hmm
are you getting a specific error?

no, it just displays the php code

hmm
sounds like a config issue
is the file extension .php ?

yes

yeah, i wanted to learn php, mysql, and html so… i spent 85 bucks and got a domain…

do other scripts work?

yes

nice

the wamp home page php works
and phpbb works

^Hyperion: hmm, odd
there's gotta be a reason

but i have run into a problem of not knowing what to put on the site lol… i have 500 gigs of space… but only like 100 megs of webpages/pics/etc…

put whatever you want
don't feel like you have to fill up the space, though

any ideas of whats wrong?

lol you don't have 500 gigs of space on your web site.
i doubt the server has that much even

You could probably get away with a simple str_replace

no seriously

sure they may advertise 500 gigs of space

they give me 500 gigs of webspace

str_replace($bad_words_array, '', $input);

^Hyperion: when you view the page in your browser, do you see 100% of the php code?

as i said… i doubt they have 500 gigs of space available on the server as a whole

Why do you doubt that?

you couldn't fit more than a couple users on the server if you weren't overselling massively

I don't have a single computer with less than 1TB of space these days

uhh… i have a server here are work with a 1.09 TB drive…

Because I work for an ISP and we run out of CPU/RAM before space.

ahh i'm dumb, it is a warning not the code

j2daosh how much do you pay for that?

85 / year

You don't use a SAN?

^Hyperion: you're not dumb

i'm inexperienced

We do on the new servers. Old servers, nah.
j2daosh you'd probably cause the isp lots of problems if you used all 500 gigs of space

unlimited sub domains/mysql DB's/emails accounts/5 TB of bandwidth/500 gigs webspace

Well, that's probably true

lol yeah but i want to try and fill it up and see what happens

You'd almost certainly have them calling you to see if they could "help you use less"

^Hyperion paste it to us

lol

the warning or code?

If not an outright suspension. A lot of the massive oversellers have a clause in the TOS about "misusing resources"

warning

well i figure, if i pay for it… im gonna use it… somehow… i might just give out space to people lol

j2daosh who's your isp?

for i in `seq 1 1000`; do dd if=/dev/zero of=file.$i size=1M count=500; done

www.siteground.com

106 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in Zwamp\www\l2status.php on line
777 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in Zwamp\www\l2status.php on line
Offline

^Hyperion: hmm
^Hyperion: could be a firewall issue
^Hyperion: is Windows Firewall turned on?

wait

or could something else be blocking the port?

ur using wamp?

yes, those ports are open though
yes

and thats your personal website?

yes

and your using firefox as your browser?

well
its a part of it
yes

i ran into a problem like that when i was running wamp on my home system

does wamp need other ports opened?

my isp blocked port 80

I can acces the website but that code doesn't work

ohh
your code access' your DB?

that code doesn't, should just check to see if ports are open

check if your ports are matched up right… maybe your mysql is on 3305 and your trying to connect to it at 7777 or whatever port you were trying to connect to

it doesn't connect to a database
and the code works, it just shows the warnings

lol j2daosh did you read this company's terms of service?
you can't use more than 5GB of space for databases

i only skimmed it
thats ok, i cant think of using 100 megs of DB

j2daosh this account is essentially uselsss.

here is part of the code that gives the error
$flogin = fsockopen ("71.229.155.33",2106, $errno, $errstr, 1);
is there a way to tell it not to show an error if there is one?

you can't put more than 5GB of media files (INCLUDING IMAGES) on here either
in fact, you'd have to come up with 480gb of raw text files to put onto the account to hit the 500gb outside of their restrictions.

^Hyperion: you can put @ in front of the code to prevent an error from being displayed
$flogin = @fsockopen(…

ok that works, the code is working, it just showed a warning when there wasn't a response on the port, there was no warning when there was a response on the port

well that sucks

thanks

np

j2daosh this is why people who massively oversell suck
because they effectively limit your space down to a couple gigs

correction on the DB part… it says i can only have a 5 gig .sql file

but then scroll down to "Use of database resources"
says you can't use more than 10% of total db queries for more than 1 seconds
second*
quote often i see users whos sites will pick up for a minute while the others die down. apparently on their servers, this means you could get terminated?
wow my spelling is awful tonight. please excuse it.

its ok, i haven't had enough coffee either
holy crap
i should have read alot more of the TOS
lol

j2daosh yup. always read the tos. i've worked in the industry for a while now and one of my specs for working somewhere is that they don't a) oversell by a huge margin and b) have nasty tos clauses

well this TOS definately has some clauses im not happy with

how long does it take your servers to send a mail() email?

MrBojangles immediately

man, i went from wanting to block some simple words, to learning about in_array(), foreach(), array_search(), and finding out my ISP has some limits i missed before

hm. mine sometimes does it fast

it's immediate MrBojangles

and sometimes it takess a few seconds

lol well according to my TOS, it cant take too long or i might crash the server

if i write a .php page that handles incoming POST or GET variables from somewhere else and had a session_start, the incoming POST and GET variables won't be mixed up, correct?

j2daosh most hosting companies have something in that, including us. we just cut off processes after a certain amount of cpu time though, rarely suspend unless a user is spamming and eating up the server resources that way.
but we don't have limitations on how to use space, etc. :P

anyone know of a way to use php with .net other than phalanger?

Hello

ffh you shouldn't use .net since it isn't *nix friendly
hi jlhenry

mono

Invalid argument supplied for foreach() in this http://www.organicdesign.co.nz/Extension:FormMailer.php on the line where is "foreach ($wgFormMailerRecipients"
Any idea how can I correct this?

make sure you give it an array

$row)"

KairuMaiku, I'm not a php dev… so It seems difficult!

upload your code to www.pastebin.com and link it here. i'll fix it for you

KairuMaiku, thanks!!!
http://pastebin.com/d2dd5d5b5 here is the doc of the code: http://www.mediawiki.org/wiki/Extension:FormMailer It's a mediawiki extension for posting forms by mail
the error seems to be on ligne 63

jlhenry did you modify the code at all?
oh, duh.
jlhenry you need to put an email address into like 13

KairuMaiku, no
it's loaded somewhere else

$wgFormMailerRecipients = array('youremail@your.com');

I give a try
KairuMaiku, perfect!!! This file is getting informations from a config file. But I was giving it $wgFormMailerRecipients = "email@me.com";
KairuMaiku, thanks a lot!!

ah yu;
yup*
I want to set up my index page so that users can customize/add/remove certain "modules" which display things like the latest news, etc… they should be able to customize the position of these modules and such, as well. What would be the best way to go about doing this and storing their information
in the database?

have a class that manages a position, and whether or not it's visible.. create an array of those classes corresponding to your modules. I would then have a table like maybe UserModuleEntities which stores one row for each module with a corresponding userid.
that's to you KairuMaiku

Personally, I'd argue that the "best" solution to your problem is to use an existing portal/CMS solution, such as Drupal

He could be doing it for a learning experience though.

I'm not going to use Drupal on this site, heh.

I'd still argue that you'll learn more, and better, by reading existing code than by reinventing wheels

Can someone give me a hand please.

Far too much of my own coding work is required to make this work, much of which I've already done. I'd rather not integrate it with other peoples code, or deal with other peoples code.

http://rafb.net/p/3pshBk68.html my script seems to be not working properly

depends on what existing code he's reading

Learning how someone else does things doesn't always teach you as well as doing it yourself and seeing what works and what doesn't. Instead of programming by coincidence like "since X cms does it this way it MUST be the best way!"

When your class has a function that's the same name as the class itself, that's called a "constructor" in PHP4. See php.net/oop

How do I email an image that is created via GD on the fly?

Sure thing, thanks.

"Doing it yourself and seeing what works and what doesn't" is an alias for "wasting my own time". If you're worried about just copying X, investigate the way the top 10 or 20 options do it

The learning process is seldom ever time wasted. If you're talking about a production environment to get things done that's a different story.

You have to use MIME to send images in email. PEAR has a decent MIME class, I think it's at pear.php.net/MIME_Mail

Gotcha thanks.

I don't think the learning process will be horribly steep. I'm taking a look at it and classes seem to be a pretty simple concept. I've just never used them before.

Yes, they're grrreeat!

So I'd just create a table and the class would be displayed based on what the rows say, correct?

Well object oriented constructs (like classes) aren't compatible with the relational database model. You'll have to have some way to convert what you need from the class into an appropriate SQL statement.
If you're using an OO database management system, no problem.

I need a table that tells which classes are going to be on the page and in which order

So in your table have a column that defines an enumeration type of whatever values like MODULE_NEWS, MODULE_USERS_ONLINE, and so on.

yup

$objUser = SomeOtherClass-returnUserClassObject($userId); OR $objUser = new User(); $objUser-loadById($userId);

Then perhaps you'll have a static method in your class that can create a module object that you need from a result set from a query.

TML, yes I am using PEAR. But I am overlooking something I think… I can display the image host by referencing the php page that generates the image, but I need it as a file ready to attach and send…so I read it into a file and try to attach it, but it does
not appear i the email

Once you read up a bit more on classes you'll see what I mean.

Then I need to have a data column that will tell the class, for example, how the news is to be displayed. IE: limit:10;order:asc;
See, the main purpose of the site is a type of news portal, if you will, but I'd also like to allow other types of modules to be written so I have to keep it open somewhat, heh.

Whatever is easiest for you, but putting all that information into a single column breaks 3rd normal form.

Can anyone please help me with that OO concept question?

Hell I think that's even 1st normal form. hehe
What's up?

$objUser = SomeOtherClass-returnUserClassObject($userId); OR $objUser = new User(); $objUser-loadById($userId);

Unfortunately, I don't think it can be avoided in this situation.

can you strip \s but without stripping the '
?

If not, then ok.

Read the docs for the imageXXXX that you're using

Well, it could be. I could always just create more and more columns in the database
And constantly create more columns as more modules are created

TML I am using png

What is the purpose of the process? Are you trying to create a NEW user object or are you trying to get a user object that's being managed by SomeOtherClass for use?
To answer your question (which I'm fairly certain), the second option is best.

hmm… ok cool thanks

TML and read the docs… should I be 'freading' the image (from a php file resource i.e. imagecreation.php?name=$var1&shoe_size=$var2) ?

hey folks, any one have experience with fixing stdClass type messages?

The best reason I think to use a method to create an object instead of using new is if you want to return several different types of objects based on the input. For example SomeOtherClass-createUser($parms) Depending on the input of $parms that function might create any # of different
objects. I think it's called the "factory" pattern.

hi all

when I encode a simple string to an object using json_encode , I get Cannot use object of type stdClass as array

ahhhh yeah… ok i follow Consty.. i've used factory pattern beffore (unfortunately im in php4 atm)

I am looking for Percent Bar or counter that that the user will know % process that left
any idea?

so… generally factory pattern for multiple instancess, 'new/load' method (second method) for single instances?
that makes sense

Exactly.. you got it

there is one other issue. in the examples, the SomeOtherClass has a DB connection object (SomeOtherClass-DBConnect).. so i guess in the second method (single instance), i'd have to pass that object TO the User class? (or give User class a DBCOnnect of its own)
or maybe they should both extend from a core class which has a DBConnect.

I'de recommend having a dedicated object that manages your database connection and pass THAT object to any other object that needs it to do processing.

yeah ok
thanks Consty… appreciated

No problem man, good luck!

You'll use imagepng() (or whatever) to save the file to disk, and then use MIM_Mail to take the on-disk file and attach it to an email

ugh. what's the command to make a human-readable date/time from time()?

json_encode returns a string, not a class or object
php.net/date

thanks

TML yes
TML, what I was doing, is reading the file into $dat, then chunk_split(base64_encode($dat));
TML and attaching the result of the chunk_split/base64 enc
TML, so it is better to save the file to disk, then attach the disk based resource? Is there a (better then my way) way of reading it strait into memory and attaching it as a file in the email?

anyone want to mess with a little CMS I made?

Hook me up

I mean is there nice status bar in php?

http://newbold.name/wigwam/
it's not very well documented
well, not at all actually

No, you're doing it just fine.

but the idea is that it should be pretty intuitive

Got an example deployed site?

http://uncarvedblock.org
well, and http://newbold.name

TML thats what I thought, but the image never is sent
TML it does not come through at all

So examine the email that gets sent and figure out why

how do you iterate through an object in php?

it's pretty simple crap; you have a basic template, pages, etc. But I tossed in a few cool little details

You don't

TML…I think I am overlooking something…the email has no evidence of an attachment

You can dump the content from another page directly into any other page via a tag; you can also inject bits of php code into pages

then how do i find out the keys of the object?

Objects don't have keys

Nice. It seems like it's a good start. Do you plan on using classes for it? Or pretty much keeping it procedural?

Do you mean the properties?

TML so the chunk_split(base64_encode($dat)); is right?

yeah.

I've not yet learned any OOP

i have a json object and I'm trying to access the object.

php.net/get-object-vars

could the code be made any more efficient if I used classes? Or do you think it's about as tight as it can get?

cool.

I there good encrypt and decrypt in php any recommanded? also I am looking for ready made status bar , thanx/

http://php.net/mcrypt

code seems pretty solid.. might consider adding some spaces and such between logical separation for readability (like a space between assignment statements and your loops)

I think I already mentioned that json_encode() returns a *String*, not an object…

ahh, good idea

thanx

And perhaps having the html in separate files that you call from externally instead of internal, but that might be your point to keep things consistent and small

and nice status bar?

ooh, good idea

i meant decode sorry.

The phrase "status bar" has no usabale meaning here.

that worked. thanks TML.

I want to show precent till somthing is finished
the problem that if I use for , and echo it dosnt put it as one line

Right, HTTP doesn't work that way.

There are a number of ways to do that with either html or an image

The code is very readable.. you kept things clear and concise. Nothing confusing.

k
thanx

Thanks!
have you tried running it yet?

Just checking out your site running it actually.. I'm kind of lazy right now to actually install it and try it on my system. Sorry

hehe no biggie

for example, you could make a set of nested divs, with the outer one being the "bar" and the inner one having a background color to be the "done" part of the bar. But in PHP, nothing will get displayed until the script is done processing, for the most part, so you may not be getting what
you're expecting…

can you past simple example ? thanx again

divdiv style="width: 50%; background-color: blue;"/div/div

thanx
Warning: mcrypt_ecb(): Attempt to use an empty IV, which is NOT recommend in /var/www/gmail/enc.php on line 5
hmm
mcrypt work only in php5?
I use php4

No, mcrypt works fine in php4

k
so i need libmcrypt
so why I got this error
I see the support in phpinfo
cast-128 gost rijndael-128 twofish arcfour cast-256 loki97 rijndael-192 saferplus wake blowfish-compat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes

whats the best way of doing multi level includes? i have /config.php that all scripts require_once(); and config.php has require_once('functions/….'); but if i have /script/something.php with require_once('../config.php'); it fails to include
grr… nm just a type.. but is the best way to include a bunch of file require_once()?

whats the best way to test if @ is in the string

http://discuss.pastebin.com/d6ae35679 there's something from with that and i'm not quite sure what. it says it's not a valid result resource :-
oh. just me being dumb. nevermind

strpos
or strstr… first one is faster though

say I get an 'unable to write to read only file', then I get an 'unable to open database file' error after I chmod 777 the .db file, what could cause it not to be allowed to open anymore

could the file be in use by another process?

No, it should not be.

hmm

I can't even google the error I get. nothing relevant comes back.

what's the error?
oh
no error?

Hmmm

Check permissions on the directory the .db file is located in

Uncaught exception 'PropelException' with message 'Unable to execute INSERT statement. [wrapped: SQLSTATE[HY000]: General error: 14 unable to open database file]' in /media/disk/retail/framework/library/propel/runtime/classes/propel/util/BasePeer.php:296

That error can also come up when the .db file was created by a different major version of sqlite
(i.e., where sqlite2 cannot open sqlite3 database files)

Nice
Thank you
It was the directory it was in, that was the issue.
I should of asked here 1 hour ago.
Thanks!

Hey guys…
How would I go about getting a GET variable through a POST form
If that makes sense…..
form action="pr.php?num=php echo $number;?" method="get"

you mean a POST variable in GET?

Err
Well

As in, your forms show up in the URL?

Well I only want one variable to be a GET variable
The rest I want POST

action="url?arg=val"

yup, what he said.

Ah okay thanks

Note that it's sort of ambiguous whether that's actually allowed by the standard or not

actually, what you wrote but method="post"

But everything seems to simply "do what you mean"

thank you for help. I have to go now.

Okay, I'm getting started with PHP Sessions, and I know how to start one. Is it a standard affair to make sessions timeout after so many minutes of inactivity on a website?

i want to make an array of 'illegal chars'
so people cant input, ', . , ;, ", [, ] etc in the $_post
how do i make a proper array??

you just want an array of characters?

What's wrong with users submitting data with those characters?

i don't want people to have those in their usernames

like $illegal = array(',' , '.' , ':' , '"' , '\'');
?

yup

yay i got my class working

so that woul work? ok thanks

Well, there you go then.

wow
ruby on rails is so weird

agreed

necromancer agreed
lol

jinx on y'all bitches

jinx, you owe me a coke

oh my. stop copying me.

oh man
lol

what about adding a ' ?
' ' ' wouldnt work obviously

He did that already.

its in there

i think i'm gonna like using ruby on rails though

'\''

except…I DON'T KNOW RUBY OH GOD

thats '''
the \' is ' inside of ''
lol

i heard there was a similar framework for PHP
is this true?

cake

Several. Such frameworks have been around for ages.
Just about any langauge you pick probably has one.

necromancer http://www.cakephp.org

oh cool

maybe i'm just weird but i'd rather develop it from scratch
i could probably do a blog in 15 mins :P

release early, and update often

yeah me too
but i've been coding for 7 years so
i'm at a bit of an advantage
over a newbie

from scratch can be good, but a really good framework can go a long way

if i were a newbie to server-side scripting i'd choose RoR in a heartbeat

but then im mostly a c++ programmer and there is a heck of a lot of things i wouldnt want to have to do from scratch ;-)

The problem with RoR is it's so radically different than everything. Trying to migrate a rails application to php or something else would be a huge pain. Perhaps the zend framework would assist with that, but I'm not sure.
bThe problem with RoR is it's so radically different than everything. Trying to migrate a rails application to php or something else would be a huge pain. Perhaps the zend framework would assist with that, but I'm not sure./b

the only problem i've heard about RoR having

Should I ask again?

is being very slow on large, complex sites
uhh
ask what?

How could I have an actually variable where it could update the number by increasing but if I exited the script it still kept the number or should I use MySQL for this?

Okay, I'm getting started with PHP Sessions, and I know how to start one. Is it a standard affair to make sessions timeout after so many minutes of inactivity on a website?

hence why reverse proxies exist

oh there you go

Depends on the site.

from subvariance?

well, in my php.ini i have it configured to by default only end the session when the user closes the browser window/tab

Digtitalsabre usually. I have my PHPSESSID cookie last a year, but the session itself only lasts for an hour of inactivity, then gc is run

what?

Never mind.
You're a different one.

are you talking about the ruby on rails performance issues?

necromancer wouldn't that mean your server never gets rid of sessions? it can't tell when the user closes his or her browser.

Nah. :-p

i don't know, but i just set up really simple sessions
just used session_start() and a $_SESSION variable

I installed PHP recently and I still don't have php.ini (running on default settings, as it were).

it's on a remote host
i thought session timeouts were configured in the ini

necromancer, then your sessions are cleaned after 1440 seconds

oh
ok

default in php.ini means that garbage collection is run on sessions after 1440 seconds of no activity

Would it be best to just use SQL?

Is that the default? 1440 seconds?

Yes, Monie. I use a SQL session handler.
Yes, Digtitalsabre

oh ok

Monie, but mostly I use SQL because my sessions span across multiple servers

yeah how does one change that so someone can stay logged in?

A lot of people use sessions based out of the filesystem or memory

But I only want the number to increase that's all I don't have anything to insert.

necromancer, you mean like, permanantly?

yes

Is that 24 minutes?

Yes 24 minutes
And necromancer, sessions don't work that way.

Wow.

Neither sessions nor cookies really last permanantly. You can set them for a really long time, but they eventually run out.

so would i use cookies for that?
but for adding "Remember Me" functionality

You wouldn't want sessions to last for more than an hour of inactivity or so, either, because it would leave garbage on your server.

i never took the time ot figure out how to do that

necromancer then you have to use cookies. as i said, you don't want sessions staying on your server and clogging it up

oh ok
so i guess sessions are like server-side cookies

you can run sessions client-side too but that's not secure
really sessions are sort of limitless as to possibilities. handlers can be written for all sorts of types of databases, etc

wait
well
i guess i could store a sessionid in the members table

necromancer why?

I want to keep a variable of something a user said until a new user comes how would I do this?

Well, as for me, I need sessions to be secure. But I only want to use MySQL for authentication. I plan on setting up SSL for security.

Digtitalsabre sessions aren't secure if someone can get to where your sessions are stored

wow i have users

That doesn't bother me. I'm not storing personal or bank information on the server. If people can get to where the sessions are stored, the app's pretty screwed as it is.

Digtitalsabre i don't see a need for you to write your own handler for mysql anyway unless you need to use a reverse proxy to distribute load or something like that
Digtitalsabre or just a careless server admin

for session retention i guess

Where do I find a session handler that's pre-written?

Digtitalsabre PHP comes with 3 by default. most just use the filesystem one which is again, default

session_start() ?

that's all you need to do even with a custom handler

That's what I was going to do. As I said, MySQL is going to be used only for authentication.

it should automagically create a PHPSESSID cookie to store the session id across pages, and it should automatically run gc after 24 minutes of inactivity
Digtitalsabre like i said, you don't really *need* to write a custom handler unless you're like me and running servers behind a reverse proxy
i was probably a little confusing after someone mentioned it being easier to use sql, heh

What's a custom handler? Because I want people to be able to log in so they can access data.

Digtitalsabre you don't need a custom handler for that. all that a custom handler does is tell session_start() to do something of your choosing

Then what's a better way to go about it?

Digtitalsabre are you using multiple servers?

Currently, no. But perhaps when it moves to a professional server.
Er, a professional host.

Digtitalsabre you need a lot of load to justify that, and you can always change it later. for now, just use session_start() at the beginning of each file.
usually you can't find a prewritten handler and it can be a bitch to write one if you don't know what you're doing

Okay, and when folks log in?
It should grab their user information from the MySQL site and put it into $_SESSION
Er, MySQL table.

Digtitalsabre it should grab their user id and put it into $_SESSION
and when they log out, it should unregister their user id from$_SESSION

And test their password, no?

no need to test their password every pageload with sessions, because they can't go and modify a cookie or anything to change it

So using sessions in the default way have behavioral problems when you're serving distribute load for web server & database server?

Yup.

No, I know it should only test their password once.

Makes sense, but you'd think there'd be some way for the servers to communicate and transfer session data among each server
Internally.. how do you handle it then?

I suppose you could store the session files on a network location where all servers can access, but it's better to do it over the database. More efficient.
Digtitalsabre yes. Test their password on login and then only store the user id or username in the session
Right now I'm having them run from MySQL, but when I get a memcached server set up, that will be the primary access point, in addition to the database.

Interesting

User_id is better. It's the primary key and all the other MySQL data refers back to it somehow. Except the reference tables.

Basically the handler right now grabs from SQL. In the near future, it will check memcached first, if there, grab it from there — if not, grab it from sql and insert it into memcached for future use
Digtitalsabre yup. I use user_id as well.

I'm extremely vauge when it comes to distributed/cluster computing, so it's interesting to see what people do to make things work in such an environment

I'm pretty new myself, learned a lot in this channel.
Not completely green, because we cluster a lot of mysql databases and reverse proxy a lot of static pages for our clients at work, but I've never worked firsthand with dynamic web sites on large scale ops before.

Cool

Yup. Supposedly memcached is pretty neat, too. Stores whatever you put into it in the ram

http://pastebin.com/d37980893 This is my header file called sess_dbreq.ini. It's loaded using require(). Good?

So you're sort of a systems admin with added programming responsibility?
Or the other way around?

yo fellas, trying to insert some info havin a bit of problem @ http://phpfi.com/255644

Digtitalsabre not familiar with mysqli. So long as session_start() is included before you start sending page content though, it's fine.
I do a few things for work, my official title is tech support, but I do a lot of systems admin work and systems design because I'm pretty good at it.

hey nickelnick

Programming is something I do on my own.

your problem is that you aren't enclosing your $_POST with {}

The reverse proxy/mysql cluster/memcached solution is for my own upcoming project

So require() before title, or before… DOCREF?

Digtitalsabre require() before !DOCTYPE

Er… Is that okay?

http://pastebin.com/d29fc3d57 Is the example code (obviously not trying to actually do that just to show you what the theory of what I'm trying to do is) . Is there anyway to do something like that without having to actually do a whole new
query?

err

Digtitalsabre yes, because you're not actually sending any data to the page.

yea sno
i fawked that one up good
try this one
php
include ("connect.php");

$month=$_POST['m'];
$day=$_POST['d'];
$year=$_POST['y'];

here let me fix it up for you nickel

$eventdate="$year$month$day";

I hope you don't get paid for tech support only.

and don't spam the room

$insert_date="INSERT INTO que (`name`, `describe`, `date`, `offer`, `email`) VALUES ('$_POST['name']','$_POST['describe']','$eventdate','$_POST['offer']','$_POST['email']')";

nickel!

stop

mysql_query($insert_date);

ah too late

he pressed paste

?
shit
sorry
fellas
sorry guys, i didnt mean to

Nah, I don't get paid for only tech support. My boss is a decent guy.

http://phpfi.com/255645
thanks sno

http://phpfi.com/255646
there you go

rad sno
thanks a bunch

I do a lot of systems design for our larger clients and get commission on top of that. Whatever systems admin work or emergency work I do is paid on top of that as well.

I want to SELECT column1,column2 FROM blah and if num_rows for column1 is greater than 0 do something specific and if num_rows for column2 is greater than 0 do something specific.
What do I do?

My boss pretty much rocks too and takes us out to good restaurants

you really should check security though

http://pastebin.com/d29fc3d57 For specific code

you ask #mysql

if you don't have magic quotes on you should use mysql_real_escape_string to all your values
and not use raw values

right

your begging for somebody to sql inject and kill your DB

but you can't do that afaik

KairuMaiku, I would need to make an entirely new select statement right?

so other than that what did i do wrong?

but my question is, how can you have a different number of rows on different columns?

sno are those backticks?

backticks where?

KairuMaiku, Yeah, that's probably a good point . I'm just gonna make different select statements for each column.

it really doesn't matter what you use
“ or '' or ""
as long as it doesn't escape php
its AOK

your question isn't feasible, because rows belong to tables alongside columns, they don't belong to columns
you can't have a different number of rows from column1,column2 unless they're in different tables… and even then it would be 2 select statements
from 2 tables.

well you could do one select statement
it would just be very complicated

Sno, but he wants a num_rows on each table

I guess

other than the {}'s what did i do wrong

yea you are right the best he could do would be a compound query with count
which would be messy
not much really

ld\\

its just not secure

yea but it should still work like that right?

or a count on each table

and it doesnt

what i'm wondering about is what the hell kind of database structure he has to warrant that

yea it should work
no clue. I just got back into php/mysql about a month ago after taking a 2 year break

KairuMaiku partitions?

hm?

i am learning phpmysql too

I knew it well already

Know your way around mysqli?

I just got bored of it
mysqli?
hrm
give me a sec

it doesnt

I jumpted into this question half way and am trying to feel my way through

nope
well what kind of errors are you getting?

his question about fetching num_rows from 2 different tables?

no error
just no insertion

try making a fake query first and put it into the table using phpmyadmin or something
then if that works

i did

ok

sec

then add mysql_error code
add a line like this
$result = mysql_query($query) or die("bA fatal MySQL error occured/b.\nbr /Query: " . $query . "br /\nError: (" . mysql_errno() . ") " . mysql_error());
and it will tell you what is wrong

nvm im just a retard

its ok
we are all retards in the beginning

$query = "select table_a.column_a, table_a.column_b, table_a.column_c table_b.column_a from table_a, table_b where table_a.column_a = table_b.column_a and table_a.column_b like '%".$searchterm."%'"
Will it be secure?

I've coded PHP (read:poorly) for more than 2 years now and my code is still retarded.

lol that happens too

hi all

It's amazing how much nicer people generally are in here than in a room like #java. People in there are like read this, read that, you idiot why are you doing it this way? Use this! Basically everything but help you.

lo there DARKGirl

Digtitalsabre are you making it safe first?

only idiots like java

so…I *finally* been able to create a mysql database!
now I have a lot of nice php questions

sounds good DARKGirl shoot away

Checking for proper slashes and the like?

its a messy query
but it works

Messy?

yea

maybe you all can steer me in the direction of a clear and concise tutorial to help me with what I need, but anyway. My goal is to use Mysql and php for a user login sustem

Every language has its use. Java is a good choice for real-time cross-platform easily accessible games. If Adobe offered their Flash studio on multiple platforms though I'm sure that would change.

(system)

it works perfectly
just doesn't read well

now, im not too afraid to code in php because its similar to c

this is true…

and i know c well enough

Well, it's just an example.

but I still don't like it… lol

queries aren't made to read well. how would you write it?

Aside from the naming scheme, is there something you would do to clean it up?

just to let you know, I am using dreamweaver to make my programming time a lot more efficient

Agreed. You have to spend like hours figuring out how to use 6 different classes together to do one thing.

Digtitalsabre are you running addslashes() on it first?

I make them look prety

but there are some things I stull dont understand, like

naw should be fine

Digtitalsabre the rule of thumb is always addslashes() on anything going into the database

so THATS where you vanished to
ah ha! I found you!!!

well for mysql

hehe

Digtitalsabre just don't forget to stripslashes() when it comes out

okay so for the4 other part

let me tell you what I have so far Sno

which i farked up
http://phpfi.com/255648

use mysql_real_escape_string

I have a form with two fields and a button

it shows something but incorrect

Yeah, I am.

one is username and the other is password
the button is 'login'

'%foo%' is a bad idea

I was told I can use forms with php

yep

that works too.

so I guess the general idea is to grab the data from the form fields, log into the mysql database and do a search for the username. if I find a username, I see if the password matches

why do you think %foo% is a bad idea besides eating resources

and if they both match, then I create a session via a cookie?

so you need basic user login scheme?
well

the reason that it eats resources is what makes it bad

Digtitalsabre ini_set('magic_quotes_gpc',0) first in your requires file though because otherwise mysql_real_escape_string will escape it twice

aye

php is nice cause it does that automatically
so to set session info all you have to do is start it and then set it

start what?
set what?

session_start();

Why is %bar% a bad idea?

might you have suggestion for http://phpfi.com/255648

nickelnick i'll look at it. stop bugging sno

then set a session info via $_SESSION['var']=stuff here;
and its all good
lol its ok

nickelnick what error is it giving?

Odd confusing question, I have an array, $array = Array ( Array ( "a" = 6, "b" = 3 ), Array ( "a" = 2, "b" = 5 ) ); —– Is there a way to sort this multidimensional array by the variable "a", so their order will pretty much be swapped because the value of "a" in the second array is smaller
than the value of "a" in the first array.

aye, but do you have any links on how to code a basic login scheme?

the database server will not be able to utilize an index on that query

um hrm… give me a sec
though you can just google them usually

ive tried, believe me

nickelnick i see what you're trying to do. let me fix it

I kept coming up with crap that has nothing to do with what i want

lol

Can you explain that a bit?

nickelnick, what data do you want to display in the loop?

I recognize this isn't really the right place for this
but does anyone know any XSLT
I'm not sure how to escape things
for instance "'s

sorry was disconeted. did i miss anything

nickelnick i'm fixin ur shit.
nickelnick what do you want displayed in the loop?
nickelnick which columns?

when you start data with a wildcard the indexing becomes useless, as the index would usually cut down the filesort by eliminating records that do not start with the correct characters.

xD

KairuMaiku lmfao

nickelnick, what columns do you want displayed in your loop

all of them

i don't know what your columns are, nickelnick. give me their names :P

but i want only the dates within one week
names, describe, date, offer, email

lol

nickelnick http://phpfi.com/255649

very nice KairuMaiku

thanks sno

thanks guys

though nickelnick if i were you, i'd be using time() instead of writing out dates.

ill do some comparison
hrm
i was going to
at one point

I agree with KairuMaiku
time() is always more reliable and more flexible

yup. convert it as you like when you like.

for scaling and upgrading makes life a hell of a lot easier

date between $lastweek and NOW() works too

and besides. time will always continue, dates may not necessarily do so.
a communist government might take over the world and decide that calendars are for wusses and throw them all out, but time, as i said, always continues no matter what
though that's a horrible example that, by the looks of it, killed irisblaze and buzztracker, and manunderground
it could be true!

lol

but by using time you also reduce your database size by miniscule amounts

thx guys, my gf givin me the evil eye gtg
thx again

or in my case i once saved nearly a gig of space by converting my db and script to use time instead of dates. ..
..*

i've been reading conflicting things that say using mysql_real_escape_string doesn't really protect you from sql injection attacks anymore than addslashes. is this true?

Gah.

its back and forth
it really doesn't matter in the end

How can I make it free a listening socket so that the machine doesn't get trapped with it again.

its just that in the future if php is upgraded and for some reason there is some change in mysql
it will compensate for that
mysql_real_escape_string is basically the same as add slashes

i know it's better as far as makin sure it wont have 'corrupt' data into mysql but dont see how it's safer from attacks
so it's still the better choice to use regardless when dealin with mysql

the only way to be truly safe is to not use mysql. or php. or the internet. or computers.

$ php phpbnc.php
socket_bind(): unable to bind address [98]: Address already in use in /home/maxdamantus/php/socketbnc.php on line 40
How can I close the socket in such a way so that that doesn't happen next time?

kairumaiku of course but you can be safER and that matters :P

usually i just prefer to make it so users can't input any data but alphanumeric, periods, and a couple other things

yea basically

all my scripts spit back anything that's not what i want to go in the database.

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

Comments are closed.


Blog Tags:

Similar posts: