Re: [PHP-DB] Shift_JIS Character Set
On Friday 12 December 2003 14:47, Ng Hwee Hwee wrote: i'm doing a form (form.php) 1) user comes to form.php 2) user enters details and press submit 3) details get passed to form action verify.php 4) verify.php puts all the $_POST into an array $formVars 5) verify.php session_register(formVars) 6) if there is an error, verify.php sends user back to form.php 7) form.php echos all the $formVars (i.e. details that user has previously entered) in their respective textfields, together with the error messages i need to stripslashes at Step7 because as you have mentioned in a previous post on this list, magic_quotes_gpc added slashes to all my $_POST. Thus, since I need to echo them, I need to stripslashes.. I tried echoing the $formVars without the stripslashes and I see all the slashes before the quotes and backslashes etc.. so, by right, with English characters, i still need to stripslashes. OK, if you *know* that the data has been through addslashes() (or equivalent eg magic_quotes_gpc) then doing a strip_slashes() should revert the data to its original form. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* The sheep that fly over your head are soon to land. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Shift_JIS Character Set
yes, and that's why i'm appealing for help on how to stripslashes when it comes to the Shift_JIS character set... will really appreciate advises! thanx lots! - Original Message - OK, if you *know* that the data has been through addslashes() (or equivalent eg magic_quotes_gpc) then doing a strip_slashes() should revert the data to its original form. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] NEXTVAL Question
put the schema name before the sequence object you need to increment, i.e. $sql = select SCHEMA.TEAM_SEQ.NEXTVAL as \nextval\ from sys.dual; Regards, Neil Morgan -Original Message- From: Paul Miller [mailto:[EMAIL PROTECTED] Sent: 12 December 2003 00:05 To: [EMAIL PROTECTED] Subject: [PHP-DB] NEXTVAL Question Does anyone know how to make this work??? $sql = select TEAM_SEQ.NEXTVAL as \nextval\ from sys.dual; I get the following error in PHP: ociexecute(): OCIStmtExecute: ORA-00903: invalid table name But when I use my SQL tool to hit the DB will all the same parameters, it works just fine. I have also tried: $sql = select TEAM_SEQ.NEXTVAL from sys.dual; $sql = select TEAM_SEQ.NEXTVAL from dual; all with the same results. I am running Red Hat AS, PHP 4.3, OCI8 Functions and Oracle 9i. - Paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Need help!!!
Hi.. Anyone can help me with this script???I kept getting error saying i did not define the variable $tutor_id and whenever I define it as $tutor_id = $_POST ['tutor_id'], I got error saying there was an Undefined index! What was exactly the problem?? Need help desperately , greatly appreciate any suggestions/help/solutions given... --- ===edit.php $dsn = mysql://root:[EMAIL PROTECTED]/tb1; $db = DB::connect ($dsn); if (DB::isError ($db)) die ($db-getMessage()); $action = $_GET[action]; if($action == delete) { $sql = mysql_query (DELETE FROM tutor WHERE tutor_id='$tutor_id'); } if($action == edit) { $sql = mysql_query (SELECT * FROM tutor WHERE tutor_id ='$tutor_id');**ERROR HERE!!* $row = mysql_fetch_array($sql); echo form name=\edit_tutor\ method=\post\ action=\edit2.php\; echo Tutor ID : .$row['tutor_id'].br; echo input type=\hidden\ name=\tutor_id\ value=\.$row ['tutor_id'].\; echo Name : input name=\tutor_name\ type=\text\ value=\.$row ['tutor_name'].\br; echo Contact No : input type=\text\ name=\tutor_contact\ value=\.$row ['tutor_contact'].\br; echo E-mail : input type=\text\ name=\tutor_email\ value=\.$row ['tutor_email'].\br; echo Profile : input type=\text\ name=\tutor_profile\ value=\.$row ['tutor_profile'].\br; echo input type=\submit\ name=\Submit\ value=\Update\; echo /form; } ? $result = $db-query($sql); if( DB::isError($result) ) { die ($result-getMessage()); } --- Irin. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Need help!!!
how are you getting the $tutor_id var?, in your script you are using $action = $_GET[action]; so you will need to define $tutor_id like $tutor_id = $_GET['tutor_id'], or just use $_GET['tutor_id']. a form can only put variables in the POST array OR the GET array, and if your using hyperlinks to access this script then they will of course be GET vars. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 12 December 2003 09:38 To: [EMAIL PROTECTED] Subject: [PHP-DB] Need help!!! Hi.. Anyone can help me with this script???I kept getting error saying i did not define the variable $tutor_id and whenever I define it as $tutor_id = $_POST ['tutor_id'], I got error saying there was an Undefined index! What was exactly the problem?? Need help desperately , greatly appreciate any suggestions/help/solutions given... --- ===edit.php $dsn = mysql://root:[EMAIL PROTECTED]/tb1; $db = DB::connect ($dsn); if (DB::isError ($db)) die ($db-getMessage()); $action = $_GET[action]; if($action == delete) { $sql = mysql_query (DELETE FROM tutor WHERE tutor_id='$tutor_id'); } if($action == edit) { $sql = mysql_query (SELECT * FROM tutor WHERE tutor_id ='$tutor_id');**ERROR HERE!!* $row = mysql_fetch_array($sql); echo form name=\edit_tutor\ method=\post\ action=\edit2.php\; echo Tutor ID : .$row['tutor_id'].br; echo input type=\hidden\ name=\tutor_id\ value=\.$row ['tutor_id'].\; echo Name : input name=\tutor_name\ type=\text\ value=\.$row ['tutor_name'].\br; echo Contact No : input type=\text\ name=\tutor_contact\ value=\.$row ['tutor_contact'].\br; echo E-mail : input type=\text\ name=\tutor_email\ value=\.$row ['tutor_email'].\br; echo Profile : input type=\text\ name=\tutor_profile\ value=\.$row ['tutor_profile'].\br; echo input type=\submit\ name=\Submit\ value=\Update\; echo /form; } ? $result = $db-query($sql); if( DB::isError($result) ) { die ($result-getMessage()); } --- Irin. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Need help!!!
Yes I'm using a hyperlink to access this page (see below) echo tda href=\edit.php?id=.$row [tutor_id].action=edit\Modify/a/td; and so I defined my variable $tutor_id as $tutor_id = $_GET['tutor_id']; but i still got the error: Undefined index: tutor_id in /usr/local/apache/htdocs/tutor/edit.php WHat could be the problem?;( --- how are you getting the $tutor_id var?, in your script you are using $action = $_GET[action]; so you will need to define $tutor_id like $tutor_id = $_GET ['tutor_id'], or just use $_GET['tutor_id']. a form can only put variables in the POST array OR the GET array, and if your using hyperlinks to access this script then they will of course be GET vars. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 12 December 2003 09:38 To: [EMAIL PROTECTED] Subject: [PHP-DB] Need help!!! Hi.. Anyone can help me with this script???I kept getting error saying i did not define the variable $tutor_id and whenever I define it as $tutor_id = $_POST ['tutor_id'], I got error saying there was an Undefined index! What was exactly the problem?? Need help desperately , greatly appreciate any suggestions/help/solutions given... --- ===edit.php $dsn = mysql://root:[EMAIL PROTECTED]/tb1; $db = DB::connect ($dsn); if (DB::isError ($db)) die ($db-getMessage()); $action = $_GET[action]; if($action == delete) { $sql = mysql_query (DELETE FROM tutor WHERE tutor_id='$tutor_id'); } if($action == edit) { $sql = mysql_query (SELECT * FROM tutor WHERE tutor_id ='$tutor_id');**ERROR HERE!!* $row = mysql_fetch_array($sql); echo form name=\edit_tutor\ method=\post\ action=\edit2.php\; echo Tutor ID : .$row['tutor_id'].br; echo input type=\hidden\ name=\tutor_id\ value=\.$row ['tutor_id'].\; echo Name : input name=\tutor_name\ type=\text\ value=\.$row ['tutor_name'].\br; echo Contact No : input type=\text\ name=\tutor_contact\ value=\.$row ['tutor_contact'].\br; echo E-mail : input type=\text\ name=\tutor_email\ value=\.$row ['tutor_email'].\br; echo Profile : input type=\text\ name=\tutor_profile\ value=\.$row ['tutor_profile'].\br; echo input type=\submit\ name=\Submit\ value=\Update\; echo /form; } ? $result = $db-query($sql); if( DB::isError($result) ) { die ($result-getMessage()); } --- Irin. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Thanks alot Griffiths!=)
Thanks alot for your help! That was very careless of me..;p I was stil quite a newbie to php-db coding... By the way one last favour to ask of u hope u dun mind... I have a script which was used to INSERT data into the database: (See script below): But everytime when I execute it I got the error DB constraint I think the problem lies here: $sql = INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, tutor_profile) VALUES ($tutor_name,$tutor_contact,$tutor_email,$tutor_profile); Whenever I single quote the string value: VALUES ($tutor_name','$tutor_contact','$tutor_email','$tutor_profile'); it actually insert a NULL value into the DB though I did enter values into the text field.But if I dun quote it, I got the error: DB constraint. By right I ought to quote it right?? I have gone thru my code umpteen times but to no avail. Where have i gone wrong??? ;( --- $dsn = mysql://root:[EMAIL PROTECTED]/table1; $db = DB::connect ($dsn); if (DB::isError ($db)) die ($db-getMessage()); //create variables ready to go into DB $tutor_name = $db-quote($_POST[tutor_name]); $tutor_contact = $db-quote($_POST[tutor_contact]); $tutor_email = $db-quote($_POST[tutor_email]); $tutor_profile = $db-quote($_POST[tutor_profile]); $sql = INSERT INTO tutor (tutor_name, tutor_contact, tutor_email, tutor_profile) VALUES ($tutor_name,$tutor_contact,$tutor_email,$tutor_profile); $result = $db-query($sql); if( DB::isError($result) ) { die ($result-getMessage()); } ?HTML head titleAdd Tutor/title !-- **CSS and HTML** -- /head body div align=center div id=pagecontent5 ?php if( $_POST[submit] != Save ) { ? div align=center form name=classinfo action=?php echo $_SERVER[PHP_SELF]; ? method=post input type=hidden name=form_submitted value=1 table name=add_tutor border=0px cellpadding=0 cellspacing=2 width=900tr td class=lighter width=200Name:/td td class=lighter width=500Input type=text size=50 name=tutor_name/td /tr tr td class=darker width=150Contact No:/td td class=darker width=150Input type=text size=30 name=tutor_contact/td /tr tr td class=lighter width=150Email:/td td class=lighter width=150Input type=text size=50 name=tutor_email/td /tr tr td class=darker width=150Profile:/td td class=darker width=150TEXTAREA class=textarea NAME=tutor_profile ROWS=6 COLS=70 /TEXTAREA /td /tr tr td class=lighter width=150/td td class=lighter width=150a href=teacher_summary.php div align=centerinput type=submit name=submit value=Save/div/a/td /tr /table /form br ?php } else {? table border=0 tr td class=darker width=300Teacher:/td td class=darker width=600 ? echo $_POST[tutor_name]; ? /td /tr trtd class=lighter width=300Contact No:/td td class=lighter width=600 ? echo $_POST[tutor_contact]; ? /td /tr tr td class=darker width=300E-mail Address:/td td class=darker width=600 ? echo $_POST[tutor_email]; ? /td /tr tr td class=lighter width=300Profile:/td td class=lighter width=600 ? echo $_POST[tutor_profile]; ? /td /tr /body /html /div /div ?}? --- (I'm terribly sorry if the code is kinda messy) All help are greatly appreciated! Irin. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] pg_result_error()
El Vie 12 Dic 2003 00:09, Gerard Samuel escribió: What good is this function? A quick example of the wall Im running into - $sql = 'INSERT INTO .'; $result = pg_query($conn_id, $sql); if ($result === false) { var_dump( pg_result_error( $result ) ); I would use here this: die(pg_result_error( $result )); } According to the manual, pg_result_error takes the result resource. If that resource is boolean false for one reason or another, then pg_result_error isn't useful. Anyone has any other ideas, besides using pg_last_error()? Did you try it? -- 08:43:01 up 16 days, 14:59, 2 users, load average: 0.20, 0.37, 0.36 - Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar' Centro de Telematica | DBA, Programador, Administrador Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] More of a question rather than seeking code. :)
On Friday 12 December 2003 20:15, JeRRy wrote: [snip] I just recently added a flag in the database so if the email bounces I manully flag the account as a bad email so in future emails won't be sent to that users email unless they correct their email. This is time consuming. [snip] Do yourself a big favour and setup something using a real mailing-list software. Any decent mailing-list manager will handle bounces automatically. Sustained bounces from an email address will eventually lead it to being suspended or unsubscribed automatically. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Youth. It's a wonder that anyone ever outgrows it. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] anyone trickier than 'LIKE' ?
Hi all, I have this data (eg.) ..big fat buddy... on the database . If a person enter big buddy in the search form , the ...big fat buddy. data will not be found . Any suggestion ? Thanks in advance. select * from table where data like %keywords%; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] anyone trickier than 'LIKE' ?
I have this data (eg.) ..big fat buddy... on the database . If a person enter big buddy in the search form , the ...big fat buddy. data will not be found . Any suggestion ? select * from table where data like %keywords%; You can break up the search terms into words and do ...data LIKE '%$keyword[0]%' OR data LIKE '%$keyword[1]%'... This will be slow though. You could also do full text searches if you are using MySQL. Have good indexes for whichever route you go. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] anyone trickier than 'LIKE' ?
$keywords = str_replace(' ','%',$keywords); select * from table where data like %keywords%; -Original Message- From: Hadi [mailto:[EMAIL PROTECTED] Sent: 12 December 2003 13:21 To: [EMAIL PROTECTED] Subject: [PHP-DB] anyone trickier than 'LIKE' ? Hi all, I have this data (eg.) ..big fat buddy... on the database . If a person enter big buddy in the search form , the ...big fat buddy. data will not be found . Any suggestion ? Thanks in advance. select * from table where data like %keywords%; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] pg_result_error()
Im going to CC this to the PostgreSQL list also. On Friday 12 December 2003 06:44 am, Martin Marques wrote: El Vie 12 Dic 2003 00:09, Gerard Samuel escribió: What good is this function? A quick example of the wall Im running into - $sql = 'INSERT INTO .'; $result = pg_query($conn_id, $sql); if ($result === false) { var_dump( pg_result_error( $result ) ); I would use here this: die(pg_result_error( $result )); That is fine and all, but my original example was just an example of the non functionality of pg_result_error(), not how to handle errors when a query fails. But for arguement sake, lets use your example in some dummy code[0]. $result is still boolean false, and pg_result_error() will still return an empty string, and using die, would just die, with no report of what happened. Then whats the use of pg_result_error(). According to the manual, pg_result_error takes the result resource. If that resource is boolean false for one reason or another, then pg_result_error isn't useful. Anyone has any other ideas, besides using pg_last_error()? Did you try it? Yes I've tried it. In my DB class, Im currently using both pg_result_error() and pg_last_error(), with pg_last_error() being secondary (a fall back) to pg_result_error(). Because according to the manual - http://us2.php.net/manual/en/function.pg-last-error.php --quote-- Error messages may be overwritten by internal PostgreSQL(libpq) function calls. It may not return appropriate error message, if multiple errors are occured inside a PostgreSQL module function. Use pg_result_error(), pg_result_status() and pg_connection_status() for better error handling. --quote-- So again, I beg the question. What good is pg_result_error(), when you *must* feed it boolean false and it returns an empty string?? [0] ?php $conn = pg_connect(dbname=foo user=bar password=pass); $sql = 'SELECT * FROM flagss'; // flags was misspelled $result = @pg_query($conn, $sql); // returns false if ($result === false) { die( pg_result_error($result) ); // results in an empty page } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] pg_result_error()
El Vie 12 Dic 2003 11:19, Gerard Samuel escribió: Im going to CC this to the PostgreSQL list also. On Friday 12 December 2003 06:44 am, Martin Marques wrote: El Vie 12 Dic 2003 00:09, Gerard Samuel escribió: What good is this function? A quick example of the wall Im running into - $sql = 'INSERT INTO .'; $result = pg_query($conn_id, $sql); if ($result === false) { var_dump( pg_result_error( $result ) ); I would use here this: die(pg_result_error( $result )); That is fine and all, but my original example was just an example of the non functionality of pg_result_error(), not how to handle errors when a query fails. But for arguement sake, lets use your example in some dummy code[0]. $result is still boolean false, and pg_result_error() will still return an empty string, and using die, would just die, with no report of what happened. Then whats the use of pg_result_error(). Looks like you are totally right. Tried it and it works horrible. Any idea on why this is like this? P.D.: I had to pass my php4 in Debian to unstable to get a workable (with the newer capabilities) version. Very annoing, especially becuase I had to pass apache to unstable as well. :-( -- 12:13:01 up 16 days, 18:29, 3 users, load average: 1.32, 0.90, 0.67 - Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar' Centro de Telematica | DBA, Programador, Administrador Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MSSQL Error message
Hi I´m using a connection using php 4.3.3 with sql server ... and i´m having a error message : mssql error: [: Connection error to server '192.0.0.6\binotto' with user 'LUA'] .. The user 'LUA' is the dbowner ... anyone can help me??? Sorry my bad english ... Liana Cristine Leopold
RE: [PHP-DB] Cronjob
One thing I might suggest is to queue up your inserts, then use the extended insert syntax to populate several records at once in a single INSERT instead of 12 separate ones. I believe you can alter the /etc/my.cnf file to play more 'nice' as far as priorities and memory, but I've never touched it -Original Message- From: Ryan Marks [mailto:[EMAIL PROTECTED] Sent: Thursday, December 11, 2003 6:45 PM To: PHP-DB Subject: [PHP-DB] Cronjob Hello all, I have a cronjob that runs a PHP script against MySQL. The script takes 5 minutes to process 4000 records (approximately 12 records per second). Here are the top two entries from top: PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 8671 mysql 25 0 20172 19M 2000 R97.8 3.9 2:02 0 mysqld 8670 appmgr15 0 2088 2088 1424 S 2.2 0.4 0:03 0 php Is there a way that I can slow down the script so mysqld does not bog the machine down. Here is a snippet of code. The function is called by the cronjob. snip function rank_mailbox_current($company_ID){ $query = select app_ID from mailbox where company_ID = \$company_ID\ and deleted_date = 0 order by mailbox.ID desc; $result=query_database($query); while ($row = mysql_fetch_assoc($result)){ $app_ID = $row[app_ID]; $rank_of_app=rank_app($app_ID,$company_ID); } } /snip Server: P-IV 2.4GHz, 512 DDRAM, RedHat 9 PHP Version 4.3.1 MySQL 4.0.3 Thanks, Ryan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] [PHP-DB] pg_result_error()
On Friday 12 December 2003 10:24 am, Martin Marques wrote: That is fine and all, but my original example was just an example of the non functionality of pg_result_error(), not how to handle errors when a query fails. But for arguement sake, lets use your example in some dummy code[0]. $result is still boolean false, and pg_result_error() will still return an empty string, and using die, would just die, with no report of what happened. Then whats the use of pg_result_error(). Looks like you are totally right. Tried it and it works horrible. Any idea on why this is like this? Seems like Im not the only one who thought this function is useless... http://bugs.php.net/bug.php?id=18747 So Im going to modify my code to not use this function, as it is really a total waste of time at the moment. Thanks for the chat... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php