logs archiveIRC Archive / Freenode / #php / 2006 / June / 7 / 11
cythrawll
basically it adds two strings together A-KO
philip
i can rarely spell that word correctly as well
richardlynch
Thank you cythrawll, as I was very befuddled about "that string"... :-)
cythrawll
yeah i had to scroll up
gregtampa
anyone know of a good site or place that i can learn about sql alter tables for php?
A-KO
ahh okay cythrawll....
thanks :D
philip
gregtampa: php, perl, python... does not matter... sql is sql
cythrawll
gregtampa, what dbms? mysql?
richardlynch
gregtampa: http://dev.mysql.com which is not PHP at all, but it will tell you all about update.
         

gregtampa
well like an install script to alter a table in sql.
ill look thank you
philip
php has functions to call sql, that's all
gregtampa
u can create tables in ur sql datrabse through php
aswell as alter edit them.
philip
you can run sql, yes that's true
Nimmit
anyone know how I can have php print to a shell in a certain color?
gregtampa
where can i learn how to insert some stuff in my sql?
philip
gregtampa: but it's not php doing anything, it's just passing on the sql
where is php-bot?!
richardlynch
Nimmit: You'd have to know the escape sequences for colors in that shell...
philip: I dunno, but stormbot is standing in, I think...
Nimmit
shell is bash
philip
TML: we need php-bot!
stormbot: hi
stormbot tell philip about sql
stormbot: you are useless! :)
gregtampa: sqlcourse.com w3schools.com/sql/
richardlynch
philip: !tell works...
philip
!tell philip about strlen
ah
gregtampa
k thx phillip
philip know where they start talking about how to write it in php? i know how to edit my sql databse easly i just wanna learn how to make install scripts for it using php.
philip
what db?
gregtampa
the sql databse
A-KO
awesome, thanks a lot for the help.
Got it working :D
philip
many databases use sql syntax
gregtampa
like i have a forum and want to add stuff to it but need to edit the sql tables.. using a sortof plugin ect.
A-KO
SQL = awesome
gregtampa: phpmyadmin?
heh
gregtampa
yes i have that
         

philip
then, mysql is your database
signature16
what does ! in front of a variable mean?
richardlynch
gregtampa: $query = <<<EOQ INSERT blah balh blah
philip
negation operator
richardlynch
EOQ;
gregtampa
i have the instruction for phpmyadmin on what i need todo but i wanted to use a *.php file todo it instead.
richardlynch
mysql_query($query);
A-KO
oh.....greg, just connect to the database, and run mysql_query("YOUR STRING HERE") or whatnot
yeah
err what richardlynch said :)
gregtampa
alright.
philip
gregtampa: all you do is pass sql to mysql_query
A-KO
richardlynch : thanks for the help, the site I'm working on is working great.
philip
$r = mysql_query("SELECT foo FROM bar WHERE baz = 42");
gregtampa
so what would i do for something like this?
--PhpMyAdmin--
*Go to e107_user table *Drop user_prefs *Create user_prefs table after user_ban *Use the following..
Field: user_prefs Type: Varchar *Length: 100 *Collation: latin1_swedish_ci *Default: a:1:{s:9:"user_gold";s:4:"1000";}
richardlynch
!tell gregtampa about pastbin
gregtampa
sorry
can i messagfe someone private
A-KO
richardlynch : I assume it's more efficient to gather as much information from one sql statement as possible?
philip
btw this is not a sql channel
A-KO
richardlynch : when using it in PHP?
cythrawll
there is a #mysql channel
richardlynch
gregtampa: All you have to do is figure out what SQL you want to execute, and then the PHP part is dead easy... Translating stuff on the GUI of phpMyAdmin to SQL isn't really a PHP topic. #phpmyadmin or #sql maybe useful.
gregtampa
okay thank you i will try there.
well i can do it on the phpmyadmin gui easliy
i just want to write a php script todo it instead.
richardlynch
A-K0: It's best to use SQL to get EXACTLY what you want in EXACTLY the order you want, and have PHP do nothing but loop through and spit it out. SQL way better at search/sort than PHP (usually).
gregtampa: We understand: But the PHP bit is a no-brainer.
gregtampa
i understand its a no brainer for u guys.. lol
A-KO
richardlynch : awesome, then I did it properly.....
philip
gregtampa: do you know how to create a string in php?
A-KO
Thankfully easier to do when I've worked with VBA/Access and sql statements for a while :/ PHP eludes me, though.....but slowly learning...
philip
$string = "a b c";
A-KO
I actually got most of it, just the tough parts of building URLs, etc......kind of got me
philip
now replace "a b c" with your query... then pass $string into mysql_query()... and that's it, on the php side
gregtampa
if i may PM one of you guys to look at the 5 lines i put how todo it in phpmyadmin and write it into a statement in php for me i qould appreicate it so i can understand better.
cythrawll
ew access
gregtampa
i think i got it so $csql "alter table" blabala
A-KO
cythrawll : Actually, believe it or not, I learned a whole lot from it--considering I needed to do a lot of stuff with the info so I just wrote functions and passed SQL statements through those functions
philip
yes
A-KO
and then did what I needed with the data
now I"m translating a lot of that over to PHP/mysql......
gregtampa
opps i messed up heh. $string= "drop e107_user";
philip
your options are unlimited :)
cheatersrealm
how can I tell how many lines I've outputted from a mysql_query's result?
gregtampa
half the people in this channel are in the mysql channel aswell.. lol
cheatersrealm
without counting, preferarbly
philip
cheatersrealm: maybe you mean mysql_num_rows
A-KO
gregtampa : all you have to do is pass a string to $query = mysql_query("string here"); with the string being your SQL query. then to access that query, use mysql_resuilt($query,n,field_name);
cheatersrealm
philip: does that decrease as I run through the thing?
philip
no
cheatersrealm
hrm
then I need to just count
A-KO
gregtampa I'll PST you an example
gregtampa
A-KO i have no clue what u just said haha
philip
A-KO: do not suggest mysql_result please :)
that is so phpfi :)
a newbie, such as gregtampa, should only use mysql_fetch_assoc()
gregtampa: go here php.net/mysql-fetch-assoc and study the example
mclaud
hallo
cythrawll
hi2u ^.^
mclaud
hi!
I'm from Italy, it's really late here...
cythrawll
i'd imagine
zircu
last minute project due?
mclaud
a question about chmode!!!
how to change it in php4 with safe mode on
TheNinthCut
IS there a function for retrieving a file extension of a file or anything like that?
philip
pathinfo() tells all
mclaud
or use regexpr
philip
but ask yourself, what is the extension of foo.bar.eh ?
richardlynch
mclaud: It's very likely that you are getting an error message that says you can't do that... You can't do that means you can't do that. You'll have to find a way to do what you want without chmod, or without safe_mode.
Or a more realistic example like config.php.inc
A-KO
okay.... richardlynch, do you have to do $query = when running an update?
philip
config.inc.php ;-)
A-KO
or can you simply run mysql_query("update.........");
mclaud
richardlynch: I create a thumbnails with GD2 and put in a dir created with ftp
TheNinthCut
philip, it's for image you think it's better to get the image type and handle the filename with a switch( ) and regex or with phpinfo()?
philip
A-KO: a query is a query is a query is a query
A-KO
kind of dumb to 'return' something when you update? or does the return result equal successful/unsuccessful?
richardlynch
A-K0: You never HAVE to do $query = but it is useful for when you screw up the query and want to add: echo $query, "<br />\n";
A-KO
ahh
okay richardlynch
thanks :)
philip
manual tells you what is returned for an update
richardlynch
A-K0: mysql_query() explains about the differences for different queries.
philip
TheNinthCut: ideally you would use the fileinfo extension
mclaud
no way to change the chmode with chmode,ftp_site (ftp_chmod is php5)
zircu
chmod*
mclaud
chmod doesn't work! it's in php safe mode
richardlynch
mclaud: You may be able to use your FTP password in a PHP script to login and do ftp_chmod, or send a raw FTP command to do the chmod, and thereby bypass safe_mode... Or you could write a suid shell script to let you do chmod. But you ain't gonna get PHP's chmod function and safe_mode to "work" on a file if the error message says you can't do that.
mclaud: zircu was merely correcting your spelling... * means "correction of above"
cythrawll
mclaud, check the comments here, it shows a hack: http://us3.php.net/manual/en/function.ftp-chmod.php
gamerplanet
this is the php chatroom?
TheNinthCut
philip, I'm looking up php.net/fileinfo it's talking about like a command during installation I don't see anything about it being a usable function in a script.
philip
TheNinthCut: it's an extension
mclaud
ftp_chmod is given as a php5 function, not useful on php4
thnx guys!!
philip
TheNinthCut: here's something i created long ago, i think it works: http://boogle.com/tmp/get_mime_type.phps
cythrawll
mclaud i know htat, but it shows a php4 method on the bottom of that page i posted
philip
TheNinthCut: the manual pages for every php extension first talks about how to install, requirements, etc. ref.fileinfo is no different. look around, you will find functions
mclaud
thanks a lot cythrawll! I'll give it a try!!! God bless you!
Zakabog
o.O
I just changed a few hundred lines of code and ran the program again and it just worked perfectly
philip
lies
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 next »