Jump to content

centenial

Members
  • Posts

    59
  • Joined

  • Last visited

    Never

Everything posted by centenial

  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!
  15. Hey, I've been working on this (simple) MySQL class. It's gone well so far, but I can't seem to call a function from within a function inside the class. I want to be able to call the safeSQL function inside the executeQuery function, so that everytime I run a query it automatically checks to make sure the "SQL" is "safe". However, whenever I try to do that, I get this error: Fatal error: Call to undefined function safeSQL() on line 53 Can't you call a function from within a function in a PHP class? I appreciate your help. I'm kind of new to this whole OOP thing.
  16. Hi, Does anyone know of a good function that makes an sql query "safe" to put inside the mysq_query() function? I tried the mysql_real_escape_string() function, but that saves a backslash in front of every quote I have in the database. Which is annoying. Anyone have some advice?
  17. Hi, I have an array/object that looks like this: ( [0] => stdClass Object ( [id] => 1 [name] => William ) [1] => stdClass Object ( [id] => 2 [name] => Tom ) [2] => stdClass Object ( [id] => 3 [name] => Michael ) ) It's stored in a variable alled $names. I tried accessing it like this: echo $names->id; echo $names->name; and like this: echo $names['0']['id']; echo $names['0']['name']; But both ways render an error. Can someone explain what I'm doing wrong?
  18. Hi, Thanks for the quick reply. That code returned this: Array ( [userid1] => [Pass1 Userid2] => [Pass2 Userid3] => [Pass3 Userid4] => [Pass4 ] => ) Which doesn't look right. Any other ideas?
  19. Hi, I have a string, like this: Userid1 Pass1 Userid2 Pass2 Userid3 Pass3 Userid4 Pass4 Each column is tab separated. I want to explode it into an array so that the userid will be the key, and the password the value. I tried to do it like this: $array = explode("\t", $string); // Where $string is the string above. However, this returned both the userid and the password as the value, and created an automatic key for each row. Can anyone help me? Thanks,
  20. Hi, I have a MySQL || OR operator question. Here's my query: SELECT id, name FROM images WHERE userid = '1' AND (field1a > 100) || (field1b > 100) AND (field2a > .2) || (field2a > .2) I want to select all records from the image table where userid = '1', where either field1a or field1b are greater than 100, and where field2a or field2b are greater than .2. The query as it is pulls the records for all users from the database, not just the ones for user1. Help anyone?
  21. Hi, I'm having trouble with an SQL query: SELECT * FROM images WHERE userid = '1' LIMIT 0,16 This returns 0 Rows. It should be returning up to 16. When I delete the "WHERE" clause, it returns 16. And when I delete the limit clause it returns every row belonging to user 1. But when I use them together it returns nothing. Can anyone help me? Can't you use a LIMIT clause with a WHERE clause? Thanks,
×
×
  • 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.