Jump to content

centenial

Members
  • Posts

    59
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

centenial's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, I have a multidimensional array that looks like this s t r 1 2 3 I want to print out the possible permutations of this into one string. Something like this: str st3 s2r s23 1tr 1t3 123 Can anyone think of a way to do this? Much appreciated,
  2. That's exactly what I was looking for... I knew JavaScript couldn't have had such a bug. Thanks!
  3. Yes. var arr = new Array(); alert(arr.length); // returns 0
  4. Hi, Can anyone explain to me the behavior of this code? I don't understand why JavaScript's Array.length property isn't updated after I delete an element from that array. var arr = new Array(); arr[0] = 'test'; alert(arr.length); // 1 delete arr[0]; alert(arr.length); // should be 0, but javascript returns 1 Am I doing something wrong, or is this a JavaScript bug? Thanks!
  5. Hi, I'm using PHP's ZipArchive class to extract a ZIP file to a temporary folder. I run a task on the files in that folder. Then I want to delete the folder. The problem is that I can't delete the folder created by the zip - I'm given this error: This is my code - any idea what I'm doing wrong? <?php $zip = new ZipArchive; $res = $zip->open('upload.zip'); if ($res === TRUE) { $zip->extractTo('upload'); $zip->close(); // do stuff here unlink('upload'); } ?> I even tried adding this before I extract the zip: mkdir('upload',0777); That didn't work. So I tried this before I unlink the folder. chmod('upload',0777); That didn't work either. Any ideas? Thanks!
  6. This is valid, because multiple instances of Task1 can run on the same gallery. I've been banging my head on this for quite some time. Appreciate the help.
  7. Sure. Valid example 1: INSERT INTO processes (0, 'process1', 'Task1','10'); INSERT INTO processes (0, 'process2', 'Task1','10'); INSERT INTO processes (0, 'process3', 'Task1','10'); Valid example 2: INSERT INTO processes (0, 'process1', 'Task1','10'); INSERT INTO processes (0, 'process2', 'Task2','20'); Invalid example 1: // invalid because Task1 and Task2 cannot run on the same gallery. INSERT INTO processes (0, 'process1', 'Task1','10'); INSERT INTO processes (0, 'process2', 'Task2','10'); Invalid example 2: // invalid because only one instance of Task2 can run on the same gallery. INSERT INTO processes (0, 'process1', 'Task2','10'); INSERT INTO processes (0, 'process2', 'Task2','10');
  8. Hi, I have a table CREATE TABLE processes ( process_id int primary key, process_name tinytext, process_type varchar(10), gallery_id int ); The `process_type`field has two possible values: Task1 Task2 Only one instance of "Task2" can run on a gallery at a time. Task1 cannot run on a gallery that is currently being used by Task2. Multiple instances of Task1 can run on the same gallery. I want to create an index that will handle this logic for me, so that if I try to insert into the table, it will return false should there be a conflict. Is it possible to do this with unique indexes?
  9. Alternatively, if you can't guarantee that the image will be a JPEG, you can try: // get the contents of the image $imageData = file_get_contents('http://snapcasa.com/get.aspx?code=4824&size=l&url=www.google.ca'); // create the image resource $imageResource = imagecreatefromstring($imageData); // save the image to disk imagejpeg($imageResource,'image.jpg');
  10. Hi all, I have a PHP OOP design question. I've done some searching in google, but wasn't able to turn up anything concrete. I'm hoping some experts can point me to the most elegant solution. I have a set of classes. All of my classes "extend" an abstract class called Base. (This class reads a config file, has a basic set of common methods, and sets up needed parameters) Most of my classes need a class called Mysql to perform database operations. Is the best way to access the Mysql class to pass it in the __constructor in each of my child classes, or to instantiate it in my Base class, and assign it to a public property? Or perhaps there is a better way altogether? I'm really looking for the best way to do this, so thanks in advance for your advice!
  11. Hi, I installed PHP on IIS 6.0 - Everything was working fine until I tried to submit a form. The PHP $_POST super global is always empty. I've checked to ensure that my form has method="post", and I don't think it's a coding error, since the same exact script is working fine on my other machine. Does anyone know why this might be? Appreciate your expertise.
  12. Hello, I have a while Loop that works something like this (I've simplified it so you can see the general logic of what I'm trying to accomplish): <?php $i = 1; while (!file_exists($completed_file)) { -- progress bar code here -- if ($i == 1) { ProcessTask(); } $i++; } ?> Basically, I want to output a progress bar while I perform a task in the background. When the task is completed it writes a $completed_file txt file, so I know when to stop the progress bar. The problem is that when it gets to the ProcessTask() function, it stops to run that WHOLE function. So basically it sits at 10% until the ProcessTask function is completed, and then it outputs everything to the page. Instead of that I want it to run the Function in the background, allowing my progress bar to run smoothly and completely. Is there a way to run a task/function in the background of the while loop, so my progress bar doesn't get interrupted? Your advice/experience is very much appreciated.
  13. Looks like you have some weird characters before your "include" and "query" lines. Try removing those. Edit: Try changing it to this: <body> <table width="480" border="0" align="center" cellpadding="3" cellspacing="3"> <tr> <td width="32" bgcolor="#D5EAB9"><div align="center" class="style3">ID</div></td> <td width="323" bgcolor="#D5EAB9"><div align="center" class="style3">POLL NAME</div></td> <td width="42" bgcolor="#D5EAB9"><div align="center" class="style3">Edit</div></td> <td width="44" bgcolor="#D5EAB9"><div align="center" class="style3">Remove</div></td> </tr> <tr> <?php include ("mysql_connect.php"); $query="SELECT (id,poll_name) FROM poll_setting WHERE (id=1)"; $result = mysql_query($query); while ($var = mysql_fetch_array($result)) { ;?> <td height="25" bgcolor="#F4F4F4"><div align="center" class="style5"><? echo ($fetch['id']); ?></div></td> <td bgcolor="#F4F4F4"><div align="center" class="style5"><? echo ($fetch['poll_name']); ?></div></td> <td bgcolor="#F4F4F4"><div align="center"><span class="style4"><span class="style5"><span class="style6"><span class="style6"><span class="style6"><span class="style6"><span class="style6"><span class="style7"><span class="style5"><span class="style8"><span class="style5"></span></span></span></span></span></span></span></span></span></span></span></div></td> <td bgcolor="#F4F4F4"><div align="center"><span class="style4"><span class="style5"><span class="style6"><span class="style6"><span class="style6"><span class="style6"><span class="style6"><span class="style7"><span class="style5"><span class="style8"><span class="style5"></span></span></span></span></span></span></span></span></span></span></span></div></td> </tr> <? }; ?> </table> Note the mysql_query() line. You'll also want to change the variables inside the while loop from $fetch to $var.
  14. Hi, I have 2 different classes. 1) MySQL - class.mysql.php 2) Cart - class.cart.php The MySQL class allows me to efficiently write/execute queries. The cart class has functions like AddToCart, UpdateCart, and DeleteFromCart. However, to perform those functions I need to connect to the database and execute a query. What is the best way to 'include' the functionality contained in the MySQL class to the Cart class? Should I do a "class extend", or simply 'include' the class.mysql.php file and create a new instance of the database class in each function? Or could I create one instance of the MySQL class ($MYSQL = new MySQL;) at the top of the Cart class and would that apply to all the functions within the Cart class? I'd like to do this the "right way", so any help would definitely be appreciated!
×
×
  • 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.