Jump to content

zeezack

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Everything posted by zeezack

  1. OK so if I give the example of making a simple news blog... an admin logs in, then creates a new news article with pictures...what would be the best way to start and what coding technologies... login check picture check - upload news
  2. mmm I am kind of new to the world of object orientated php. I was never taught web design, but I just picked up procedural methods. I did oo in JAVA. Are there any good books that can help me build my own frameworks etc...never used Zend etc... I would like to learn how to build - database connections - news blogs - login and sessions Finding this oo stuff really hard to work with in php, I've read the examples but in terms of making more sophisticated code, well never been given the opportunity. Any links or books that would help a lot?
  3. Ah so you have actually made the combo selection box itself an object... So your objects are - database connection - the sql query - the combo box list
  4. Yes how would you turn the above function into oo. :-\
  5. opps forgot to add one.. well - what should be done or not done if you wanted to set up this kind of function... and place the result into a drop down box for a form.
  6. //Request Form Class - currently grabs departments and puts them into a select box class request { // Define the function getList() - no parameters function getList() { include "includes/data1.php"; $dep .='<select name="department">'; $query_result = mysql_query ("SELECT * FROM `table` WHERE `condition` ='yes' ORDER BY 'apricot' DESC"); while ( $row = mysql_fetch_array($query_result) ) { $orgcode = $row["code"]; $codelen = strlen($orgcode); if($codelen==3) { $dep .='<option>'.stripslashes($row["name"]).'</option>'; } } $dep .='</select><br/>'; return $dep; mysql_close($Link); include "includes/data2.php"; } }
  7. I kind of do.. but how do you apply them and why in this case? public - available to all classes protected - availalbe only to the parent class private - available to only the class that defines it.
  8. What is wrong with this? Please help. Why won't anyone reply?
  9. I am having trouble trying to get this query to work... what is wrong? 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 <= ? ) WHERE r > ? Warning: ociexecute() [function.ociexecute]: ORA-00911: invalid character in /usr/local/apache2/htdocs/robtest/feed26.php on line 808 0 - CHECK Results Warning: oci_fetch_array() [function.oci-fetch-array]: ORA-24374: define not done before fetch or execute and fetch in /usr/local/apache2/htdocs/robtest/feed26.php on line 828 Warning: oci_fetch_array() [function.oci-fetch-array]: ORA-24374: define not done before fetch or execute and fetch in /usr/local/apache2/htdocs/robtest/feed26.php on line 844 has this value here is the code... please reply back soon. if($dbs[0][1]=="EBS" || $dbs[0][1]=="HRMS") { $sql = "SELECT $fldso"; $sql .= " FROM ( SELECT $alias_flds, rownum r"; $sql .= " FROM ( SELECT $flds_b"; $sql .= " FROM $k"; $sql .= " ORDER BY $indxflds"; //if scalar @idx_key > 0; $sql .= " ) alias WHERE rownum <= ? )"; // $recs_page $sql .= " WHERE r > ?"; // $recs_start } elseif ($dbs[0][1]=="CELCAT") { $sql = "SELECT $flds_b"; $sql .= " FROM (SELECT TOP ? $flds_a"; // $recs_page $sql .= " FROM (SELECT TOP ? $flds"; // $recs_end $sql .= " FROM $k"; $sql .= " ORDER BY $indxflds_ord"; //if scalar @idx_key > 0; $sql .= ") AS A"; $sql .= " ORDER BY $indxflds_a" ; //if scalar @idx_key > 0; $sql .= ") AS B"; $sql .= " ORDER BY $indxflds_b"; //if scalar @idx_key > 0; } echo'<p><b>SELECTION SQL FOR GRABBING DATA</b></p>'; echo'<p>'.$sql.'</p>'; unset($fldso); unset($alias_flds); unset($flds_b); unset($indxflds); //$sql="SELECT * FROM $k LIMIT 0,3"; //currently limiting data results... $numr=ociparse($c,$sql); ociexecute($numr); $check_num_records = ocinumcols($numr); echo''.$check_num_records.' - CHECK'; //pull out the number of records. echo'<br/>Results<br/>'; //if($check_num_records==0) //{ // echo'Currently, there is nothing in '.$k.'.',"\n"; //} //else // { while ($row = oci_fetch_array ($numr, OCI_BOTH)) { echo $row[0]." and ".$row['ID']." is the same<br>"; echo $row[1]." and ".$row['NAME']." is the same<br>"; } //FETCH RESULTS FROM FOREIGN DATABASE! while ($row = oci_fetch_array($numr, OCI_BOTH)) { echo'BIG TEST WOOOOOO HOOO '.$row[0].'<br/>'; echo'BIG TEST WOOOOOO HOOO '.$arr[0].'<br/>'; if($sql_mode==1) { $real_results[$m]= $row; //place ONLY SQL mode 1 results from table into array } for($i=0;$i<=$n-1;$i++) { $trv.="'$row[$i]', "; // a,b,c, - this makes a string with the results for each coloumn it finds... col1, col2, col3, } $trv =substr($trv,0,-2); //remove the comma from the last variable $trv = "($trv)"; // (a,b,c) - these results are placed into this format then put into an array. $mass_result[] = $trv; unset($trv); } echo''.$row.' has this value';
  10. Not sure what is wrong still guys. Please help
  11. Sorry guys did you mean like this? Probably best to give code examples from now on. <?php //define class class database { //define variables private $str_host; private $str_db; private $str_user; private $str_password; private $res_connection; private $res_result; // The constructor function __construct($str_host, $str_db, $str_user, $str_password) { // Set-up the class variables from the parameters. $this->str_host = (string) $str_host; $this->str_db = (string) $str_db; $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($str_host, $str_db, $str_user, $str_password){ // Connect to MySQL $this->res_connection = mysql_connect($this->str_host, $this->str_user, $this->str_password) or die("Connection Failed: " . mysql_error());; if(!$this->res_connection) { return false; } // Select desired database return mysql_select_db($this->str_db, $this->res_connection); } function query($sql){ // Query SQL $this->res_result = mysql_query($sql, $this->res_connection) or die("Query Failed: " . mysql_error());; } function fetch(){ // Fetch result return mysql_fetch_assoc($this->res_result); } } // Instantiate MySQL class, connect to MySQL and select database $db = new database('localhost', 'mydb', 'user', 'password'); $db->connect(); // Perform a query selecting five articles $sql = ' SELECT * FROM `BATMAN` LIMIT 0 , 30 '; $db->query($sql); // Creates a MySQLResult object // Display the results while ($row = $db->fetch()) { // Display results here print_r($row); echo''.$row[0].''; //Can't use 0 since we used fetch_assoc } ?> ?>
  12. How come I am unable to get any results? It is almost as if the commands are not working?
  13. Ah cracked it ........ now is the following code - correct - good coding practice? etc.... <?php //define class class database { //define variables var $str_host; var $str_db; var $str_user; var $str_password; var $res_connection; var $res_result; // The constructor function __construct($str_host, $str_db, $str_user, $str_password) { // Set-up the class variables from the parameters. $this->str_host = (string) $str_host; $this->str_db = (string) $str_db; $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_host, $this->str_user, $this->str_password) or die("Connection Failed: " . mysql_error());; if(!$this->res_connection) { return false; } // Select desired database return mysql_select_db($this->str_db, $this->res_connection); } function query($sql){ // Query SQL $this->res_result = mysql_query($sql, $this->res_connection) or die("Query Failed: " . mysql_error());; } function fetch(){ // Fetch result return mysql_fetch_assoc($this->res_result); } } // Instantiate MySQL class, connect to MySQL and select database $db = new database('localhost', 'mydb', 'user', 'password'); $db->connect(); // Perform a query selecting five articles $sql = ' SELECT * FROM `BATMAN` LIMIT 0 , 30 '; $db->query($sql); // Creates a MySQLResult object // Display the results while ($row = $db->fetch()) { // Display results here print_r($row); echo''.$row[0].''; //Can't use 0 since we used fetch_assoc } ?> ?>
  14. Claims no database is selected?
  15. It says query failed.
  16. Still need help here guys...what exactly is wrong ?
  17. I'm trying to query and fetch some results from an Oracle database... $VAR=1; //test if($dbs[0][1]=="EBS") { $sql = "SELECT $fldso"; $sql .= " FROM ( SELECT $alias_flds, rownum r"; $sql .= " FROM ( SELECT $flds_b"; $sql .= " FROM $k"; $sql .= " ORDER BY $indxflds"; //if scalar @idx_key > 0; $sql .= " ) alias WHERE rownum <= $VAR )"; // $recs_page $sql .= " WHERE r > $VAR"; // $recs_start } echo'<p><b>SELECTION SQL FOR GRABBING DATA</b></p>'; echo'<p>'.$sql.'</p>'; unset($fldso); unset($alias_flds); unset($flds_b); unset($indxflds); $numr=ociparse($c,$sql); ociexecute($numr); $check_num_records = ocinumcols($numr); echo''.$check_num_records.' - CHECK'; //pull out the number of records. echo'<br/>Results<br/>'; //if($check_num_records==0) //{ // echo'Currently, there is nothing in '.$k.'.',"\n"; //} //else // { while($arrayBlob = oci_fetch($numr)) { echo'test MAINS'; echo $arrayBlob['CONTRACT_FILE']->load(); } OCISetPrefetch($numr, 100); while ($succ = OCIFetchInto($numr, $row)) { foreach ($row as $item) { echo $item." "; } echo "<br>\n"; } while ($row = ocifetchstatement($numr, &$arr)) { echo'BIG TEST WOOOOOO HOOO '.$row[0].'<br/>'; echo'BIG TEST WOOOOOO HOOO '.$arr[0].'<br/>'; if($sql_mode==1) { $real_results[$m]= $row; //place ONLY SQL mode 1 results from table into array } for($i=0;$i<=$n-1;$i++) { $trv.="'$row[$i]', "; // a,b,c, - this makes a string with the results for each coloumn it finds... col1, col2, col3, } $trv =substr($trv,0,-2); //remove the comma from the last variable $trv = "($trv)"; // (a,b,c) - these results are placed into this format then put into an array. $mass_result[] = $trv; unset($trv); }
  18. but I can not seem to fetch the results.. why $numr=ociparse($c,$sql); ociexecute($numr); $check_num_records = ocinumcols($numr); echo''.$check_num_records.' - CHECK'; //pull out the number of records. echo'<br/>Results<br/>'; //if($check_num_records==0) //{ // echo'Currently, there is nothing in '.$k.'.',"\n"; //} //else // { OCISetPrefetch($numr, 100); while ($succ = OCIFetchInto($numr, $row)) { foreach ($row as $item) { echo $item." "; } echo "<br>\n"; } while ($row = ocifetchstatement($numr, &$arr)) { echo'BIG TEST WOOOOOO HOOO '.$row[0].'<br/>'; echo'BIG TEST WOOOOOO HOOO '.$arr[0].'<br/>'; if($sql_mode==1) { $real_results[$m]= $row; //place ONLY SQL mode 1 results from table into array } for($i=0;$i<=$n-1;$i++) { $trv.="'$row[$i]', "; // a,b,c, - this makes a string with the results for each coloumn it finds... col1, col2, col3, } $trv =substr($trv,0,-2); //remove the comma from the last variable $trv = "($trv)"; // (a,b,c) - these results are placed into this format then put into an array. $mass_result[] = $trv; unset($trv); } //}
  19. My code seems to bring up an error? Warning: ociexecute() [function.ociexecute]: ORA-00933: SQL command not properly ended in /usr/local/apache2/htdocs/robtest/feed16.php on line 808 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
  20. Oracle issue - this is connecting to an oracle database sooooo the sql for this according to the document should be 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
  21. I am actually translating a PERL page to PHP... according to the code... those spaces should be there?
  22. oo ooo checked the query... but it is still not working... claims the query has failed...but I know the new query here works fine.
  23. function fetch(){ // Fetch result return mysql_fetch_assoc($this->res_result); } is not a valid arguement? Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
  24. I think I have sorted out the spaces..but I still get an error? Is the mysql wrong..do I need to make an AS or something? 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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.