
zeezack
Members-
Posts
34 -
Joined
-
Last visited
Never
Everything posted by zeezack
-
What is wrong with this statement? SELECT ACTION_CODE ACTION_CODE,ACTION_LEVEL ACTION_LEVEL,ACTION_MASTER ACTION_MASTER FROM ( SELECT alias.ACTION_CODE ,alias.ACTION_LEVEL ,alias.ACTION_MASTER , rownum r FROM ( SELECT ACTION_CODE ,ACTION_LEVEL ,ACTION_MASTER FROM ACTION_CODES ORDER BY ACTION_CODE ) alias WHERE rownum <= 4 ) WHERE r > 4
-
Just launched this site, still placing graphics into it. http://www.fusionrobotdesign.com
-
Hi guys, I am stuck with how to make this database oop conenction...this is one of my first scripts using oop... please help me improve my coding practice... <?php //define class class database { //define variables var $str_schema; var $str_host; var $str_user; var $str_password; var $res_connection; // The constructor function __construct($str_schema, $str_host, $str_user, $str_password) { // Set-up the class variables from the parameters. $this->str_schema = (string) $str_schema; // It's good practice to use type-casting. $this->str_host = (string) $str_host; $this->str_user = (string) $str_user; $this->str_password = (string) $str_password; } // The destructor function __destruct() { // Close a mysql connection we might've created earlier if ($this->res_connection) { mysql_close($this->res_connection); } } /*methods*/ function connect(){ // Connect to MySQL $this->res_connection = mysql_connect($this->str_schema, $this->str_user, $this->str_password); // Select desired database mysql_select_db($this->str_host, $this->res_connection); } function query($sql){ // Query SQL $this->$result = mysql_query($sql); return $this->$result; } function fetch(){ // Fetch result $this->$row = mysql_fetch_assoc($this->$result); return $this->$row; } } // Instantiate MySQL class, connect to MySQL and select database $db = new database('localhost', 'BATMAN', 'user', 'password'); $db->connect(); // Perform a query selecting five articles $sql = 'SELECT * FROM SPARE LIMIT 0,5'; $result = $db->query($sql); // Creates a MySQLResult object // Display the results while ($row = $result->fetch()) { // Display results here echo''.$row[0].''; } ?>
-
INSERT INTO EVENTS (EVENT_STATUS,EVENT_NUMBER,LONG_DESCRIPTION,SHORT_DESCRIPTION,EVENT_TYPE,EXTENDED_EVENT,EVENT_START_DATE,EVENT_START_TIME,EVENT_START,EVENT_END_DATE,EVENT_END_TIME,EVENT_END,DURATION,USER_1,USER_2,USER_3,USER_4,USER_5,USER_6,NOTES_ID,SESSION_CODE,WEEK_PATTERN,SLOTID,RELATED_EVENT,CREATED_BY,CREATED_DATE,UPDATED_BY,UPDATED_DATE) VALUES('', '41', 'Hairdressing and English - Stage 3', 'Hairdressing', '', '', '2004-08-01', '09:00:00', '2004-08-01 09:00:00', '2005-07-31', '12:00:00', '2005-07-31 12:00:00', '180', '', '', '', '', '', '', '0', '04/05', '10000000111101111111000111110111100111111111111111101', '0', '0', 'FES', '2004-06-30', '', '0000-00-00'),('', '61', 'Hairdressing and English - Stage 3', 'Hairdressing', '', '', '2004-09-06', '09:00:00', '2004-09-06 09:00:00', '2005-06-20', '10:00:00', '2005-06-20 10:00:00', '60', '', '', '', '', '', '', '0', '04/05', '00000011111110111111100111111011110011111111111100000', '0', '0', 'FES', '2004-07-09', '', '0000-00-00'),('', '101', 'A Level Biology Intensive', 'Int Biology', '', '', '2004-09-21', '00:00:00', '2004-09-21 00:00:00', '2005-05-24', '00:00:00', '2005-05-24 00:00:00', '0', '', '', '', '', '', '', '0', '04/05', '00000000111110111111100111111011110011111111000000000', '0', '0', 'KASTURS', '2004-07-28', '', '0000-00-00'), ON DUPLICATE KEY UPDATE EVENT_NUMBER=VALUES(EVENT_NUMBER) LONG_DESCRIPTION=VALUES(LONG_DESCRIPTION) EVENT_TYPE=VALUES(EVENT_TYPE) EXTENDED_EVENT=VALUES(EXTENDED_EVENT) EVENT_START_DATE=VALUES(EVENT_START_DATE) EVENT_START_TIME=VALUES(EVENT_START_TIME) EVENT_START=VALUES(EVENT_START) EVENT_END_DATE=VALUES(EVENT_END_DATE) EVENT_END_TIME=VALUES(EVENT_END_TIME) EVENT_END=VALUES(EVENT_END) SESSION_CODE=VALUES(SESSION_CODE) CREATED_DATE=VALUES(CREATED_DATE) still get the error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON DUPLICATE KEY UPDATE EVENT_NUMBER=VALUES(EVENT_NUMBER) LONG_DESCRIPTION=VALUE' at line 1
-
MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON DUPLICATE KEY UPDATE FEE_TYPE_CODE=VALUES(FEE_TYPE_CODE), CREATED_DATE=VALUES' at line 1 trying to translate this perl script # $sql_ins = qq~INSERT INTO $my_tbl ($flds_mysql) VALUES~; # ($plcs) # $sql_dupe = qq~ ON DUPLICATE KEY UPDATE ~; # my @f = @flds_mysql; # local copy # for ( 0 .. $#idx_key ) { splice(@f,($idx_key[$_]-$_),1); } # remove idx cols # # assemble UPDATE clause # if ( $no_upd_blnks == 0 ) { # my @t = ('=VALUES(',')'); # $sql_dupe .= join(',',map{$f[$_].$t[0].$f[$_].$t[1]} 0 .. $#f ); # } else { # my @t = ('=IF(VALUES(','),VALUES(','),','.',')'); # $sql_dupe .= join(',',map{$f[$_].$t[0].$f[$_].$t[1] # .$f[$_].$t[2].$my_tbl.$t[3].$f[$_].$t[4]} 0 .. $#f ); # } # # prepare sth for INSERTing each full stack of records # $my1_sql = $sql_ins; # $my1_sql .= join( ',',map{"($plcs)"} 0 .. $rec_bunch ); # 1 more # unless ( scalar @f > 0 ) { # least some flds beyond idx flds # if ( scalar @idx_key > 0 ) { # # consider using all idx flds # $sql_dupe .= qq~ $flds_mysql[0]=VALUES($flds_mysql[0])~; # } else { # no flds at all? # $sql_dupe = qq~~; # } # } # $my1_sql .= $sql_dupe; # eval { $my1_sth[$rec_bunch+1] = $my_dbh->prepare($my1_sql); }; # # set check SQL stmt length vars # $sql_ins_len = length($sql_ins); # $plcs_len = length("($plcs)"); # $sql_dupe_len = length($sql_dupe); # $sql_len = $sql_ins_len + $sql_dupe_len; # # # $sql_std = (length($sql_ins) + length($sql_dupe)); # $sql_stub_length = (length($sql_ins) + length($sql_dupe)); # $sql_length = length($my1_sql); # #
-
What is wrong with this sql statement? INSERT INTO FEE_TYPES (FEE_TYPE_CODE,UPDATED_BY,UPDATED_DATE,CREATED_BY,CREATED_DATE,TUITION_TYPE_FEE,FES_SHORT_DESCRIPTION,FES_LONG,FES_VAT_CODE,FES_ACCOUNT_CODE,FES_TRANSACTION_TYPE,FES_ISR,LATE_FEE,REFERRAL_FEE,PRIORITY) VALUES('C NOTE', 'MYRA', '2004-05-28', 'MYRA', '2004-04-01', 'U', 'Credit Note', 'Credit Note', '', '', 'R', 'N', 'N', 'N', '0'),('CASH', 'MYRA', '2004-05-28', 'MYRA', '2004-04-01', 'U', 'Cash payment', 'Cash payment', '', '', 'R', 'N', 'N', 'N', '0'),('CC', 'MYRA', '2004-05-28', 'MYRA', '2004-04-01', 'U', 'Credit Card', 'Credit Card Payment', '', '', 'R', 'N', 'N', 'N', '0'), ON DUPLICATE KEY UPDATE FEE_TYPE_CODE=VALUES(FEE_TYPE_CODE), CREATED_DATE=VALUES(CREATED_DATE)
-
How do these pointers work? $dbs{$db}->{tbls}->{$tbl[0]} = {}; $dbs{$db}->{tbls}->{$tbl[0]}->{props} = [@tbl]; $dbs{$db}->{tbls}->{$tbl[0]}->{flds} = []; $dbs{$db}->{tbls}->{$tbl[0]}->{fnc_pre} = []; $dbs{$db}->{tbls}->{$tbl[0]}->{fnc_pst} = []; $dbs{$db}->{tbls}->{$tbl[0]}->{cols} = [];
-
I more familiar with PHP, but perhaps you guys can help me figure out what is going on with this code.... there is a section here.... that fetches the results from a mysql query... --- -- Code while ($sth->fetch) { $dbs{$row[0]} = {}; $dbs{$row[0]}->{props} = [@row]; # print join(",", @row), "<BR>\n"; # 1,CELCAT,?,4,Sybase } now from my understanding here.... $dbs[$row[0]] = {}; - that makes it an empty array? an initializer of it.. $dbs{$row[0]}->{props} = [@row]; - now does this fill in the results into an element called props... if you guys can explain in detail what exactly is going on here, it will help me a lot.
-
I have been asked to write some code that will extract details from a list. Using regular expressions in PHP I am trying to grab the NAME, NUMBER and the DESCRIPTION. I have got the number - but getting just the name and the description is eluding me. <tr valign="top"> <td nowrap> <big>1439</big> </td> <td nowrap>Amy</td> <td>Hi Guys Amy here. Raven haired lady with an electric personality and great sense of fun.</td> <td nowrap><span style="color:#333">Unavailable</span></td> <td nowrap><img src="images/lips.png" border="0" alt="No Recording Available"></td> </tr> How do I get the sentence ... "Hi Guys Amy here" and the name Amy here is the site I am working from - http://www.livebite.co.uk/includes/ukcoldajax.php and here is my current code the html is the source of that page ??? ??? $regex = "/(<td>[A-Za-z]*.*<\/td>)/"; if (preg_match_all($regex, $html, $match6)) { $i=0; foreach($match6[0] as $descriptions) { //$contents = htmlentities($descriptions); //change descriptions $pinvalue = $pinarray[$i]; echo ''.$i.'.'.$descriptions.'<br/>'; $i++; } }