l0ve2hat3
Members-
Posts
312 -
Joined
-
Last visited
Never
Everything posted by l0ve2hat3
-
i guess your right... but im bothered now... what am i missing about my concept of classes??
-
well this works, but y cant i make $db public?? so confused class pca_inventory{ public function get_price($item_number){ $db=new db_manager; return $db->mssql_value('Inventory','Price',$item_number,'ItemNum'); } }
-
yeah i went through the tutorial... i know i could use extends but i thought u might be able to do this.. class pca_inventory{ public $db=new db_manager; public function get_price($item_number){ return $db->mssql_value('Inventory','Price',$item_number,'ItemNum'); } } no go... rhodesa- any way to try to tell me what i am doing wrong with the concept??
-
**how do i access db_manager::mssql_value(), if i am in pca_inventory class???
-
How do i use php code to do $date - $singup_date
l0ve2hat3 replied to lkh11lkh's topic in PHP Coding Help
<?php $date = "2009-02-21 01:30:00"; $signup_date= "2009-02-21 01:00:00"; echo (strtotime($date)-strtotime($signup_date))/60; ?> -
how do i access mssql_value in db_manager class, if i am in pca_inventory class??? <?php class db_manager{ public $dbname="gnglatt"; public $host="MARS\PCAMERICA"; public $port="1092"; public $user="demo"; public $password="demo"; public $connection; function _connect(){ $this->connection=mssql_connect($this->host,$this->user,$this->password); mssql_select_db($this->dbname,$this->connection); } public function check_connect(){ if(!$this->connection)$this->_connect(); } public function query($query){ $this->check_connect(); $qresult=mssql_query($query) or Die($query); return $qresult; } public function mssql_value($table,$field,$id,$idfield="id"){ $sql='SELECT ['.$field.'] FROM ['.$table.'] WHERE ['.$idfield.']="'.$id.'"'; $value=mssql_result($this->query($sql),0,$field); return $value; } } class pca_inventory{ public function get_price($item_number){ return db_manager::mssql_value('Inventory','Price',$item_number,'ItemNum'); } } $item = new pca_inventory; echo $item->get_price('LUNCHSPEC'); ?>
-
ok i got it... i am not going to have it echo anything.. i was just using that function as an example without going into boring details...
-
i was just making using a basic example... i am writing a class to tie a mssql based POS system to the web so customers can place orders check inventory and prices...
-
if i were to write a class to connect to a database and lets say echo something.... would i make class to connect and a class to echo or would i make 1 class and put both functions under the class?
-
for those of you who may look at this later on, here is the solutions... <?php ob_end_flush(); $remote_file = 'remote.txt'; $local_file = 'local.txt'; $fp = fopen($local_file, 'r'); $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); $ret = ftp_nb_fput($conn_id, $remote_file, $fp, FTP_BINARY); while ($ret == FTP_MOREDATA) { // Establish a new connection to FTP server if(!isset($conn_id2)) { $conn_id2 = ftp_connect($ftp_server); $login_result2 = ftp_login($conn_id2, $ftp_user_name, $ftp_user_pass); } // Retreive size of uploaded file. if(isset($conn_id2)) { clearstatcache(); // <- this must be included!! $remote_file_size = ftp_size($conn_id2, $remote_file); } // Calculate upload progress $local_file_size = filesize($local_file); if (isset($remote_file_size) && $remote_file_size > 0 ){ $i = ($remote_file_size/$local_file_size)*100; printf("%d%% uploaded<br>", $i); flush(); } $ret = ftp_nb_continue($conn_id); } if ($ret != FTP_FINISHED) { print("There was an error uploading the file...<br>"); exit(1); } else { print("Done.<br>"); } fclose($fp); ?>
-
care to be more detailed?
-
any ideas on how to calculate how long it will take to upload a file via ftp. and maybe a progress bar?
-
put this at the top of your code error_reporting(E_ALL);
-
yes take out the brakets in all ur querys
-
i hope no one helps you
-
your ftp program most likely has options to change file permissions.. if not try cuteftp
-
is id your primary key? if so leave of reservationdate. oh and post the output.
-
[SOLVED] Form working but adding extra record???
l0ve2hat3 replied to will35010's topic in PHP Coding Help
try if (!empty($_POST['month'])) -
what does $query output now? add or die(mysql_error())
-
<?php $myFile = "test.txt"; if(file_exists($myFile))echo "you have a problem with permissions"; ?> if that code echos than you have a problem with permissions
-
how would i go about running a loop for each line of a STRING (not a file)?
-
try to copy and paste... see if this works <?php // What happens here is quite obvious. I do this in case someone clicks a link that contains id=X so that the appropriate row's content will be displayed $number = $_GET['id']; // Establishing MySQL connection mysql_connect("db_server", "username", "password") or die(mysql_error()); // Selecting database mysql_select_db("db_name") or die(mysql_error()); // Here I have a code that displays row X's content even if the user did not click any button (if he or she clicked a link with id=X). // However, I believe this code is not relevant in terms of my question // Checking if the user press the "Next" button if (isset($_POST['next'])) { button1($number); $number++; } // Checking if the user press the "Previous" button elseif (isset($_POST['previous'])) { button1($number); $number--; } else { // If $number is not set, it's set to 0 if(!isset($number)) { $number = 1; } } function button1($number) { // Finding the row with the number as id - if it exists $sql1 = "SELECT * FROM jokes WHERE id = '$number'"; $result = mysql_query($sql1); if ($result) { //Storing the number of found rows in $count $count = mysql_num_rows($result); if ($count == 1) { $row = mysql_fetch_array($result); // The rest of the code in here is irrelevant } } // End of button1 function } ?> <form action="<?= $php_SELF; echo "randomjoke.php?id=" . $number; ?>" method="post"> <input type="hidden" name="number" value="<?php echo $number; ?>"/> <input type="submit" name="previous" value="Previous"> <input type="submit" name="next" value="Next"> </form> If I did not explain myself properly, please let me know and I will try again.
-
it doesnt matter ... free, not free