Jump to content

dennismonsewicz

Members
  • Posts

    1,136
  • Joined

  • Last visited

Everything posted by dennismonsewicz

  1. Ah that makes sense! So my 2nd example is stating the $var could be an array, right?
  2. Can someone explain the difference between the following? function a(array $var) { } function a($var = array()) { } function a(Array $var) { } I have seen these recently in a script I am modifying, but not 100% sure as to what each one does. Well I know what the middle one does, but am a little confused on the 1st and 3rd one. Thanks! Dennis
  3. I am trying to create a script that will show a block of images for every nine items in an array. So it doesn't need to show the block of images for every 9 items, but every time the counter hits 9 show a block of images. Make sense? I am stumped as all get out. Thanks for all the help in advance!
  4. Ok I think I know what I need to do... Its the way a jquery slider is setup... there is an unordered list that has to have 9 items per list. So I have to figure out a way to show blocks of unordered lists with 9 items per.
  5. And what is the difference between ++$i and $i++?
  6. Wow thats a lot closer than what I could have done tonight! Thanks man! Now its cutting off at 9 images but not continuing the foreach loop to show the rest of the images.
  7. Ah gotcha... I just tried it and thats right... I am just trying to show 9 images at a time because of a photo gallery I am working on. Its built to show 9 at a time, but if there is more than 9 then a sliver of the 10th image appears on the page... I just need the script to break at the 9 and then show the next set of 9 images.
  8. Hmmm what would I do instead of using a for loop?
  9. I am working on a photo gallery script in which I need to show 9 images at a time. Here is my script so far <?php foreach($pictures->result() as $p): ?> <?php for($i = 1; $i <= 9; $i++) { ?> <div class="item"> <ul> <li><a href="images/gallery/<?=$p->category;?>/<?=$p->photo_name;?>" rel="example1" ><img src="images/gallery/<?=$p->category;?>/thumb_<?=$p->photo_name;?>" alt="#" /></a></li> </ul> </div><!-- end item --> <?php } ?> <?php endforeach; ?> At the moment the script is showing one image at a time 9 times and for every entry in my database. I have been battling this for a little while now. Thanks in advance for all of your help!
  10. I figured out what I was doing wrong. $xml = new SimpleXMLElement($result); $ticket_count = (string) $xml['count']; The first node in the XML was what I was trying to work with and I was going levels in.
  11. I am trying to retrieve an attribute from a node and I keep getting the error: Warning: main() [function.main]: Node no longer exists in /Users/dmonsewicz/Projects/noosemonsewicz/api_stuff/index.php on line 70 PHP Code $xml = new SimpleXMLElement($result); $arr = $xml->tickets->attributes(); echo $arr['count']; XML <tickets count="0" type="array"></tickets> Any ideas on what I may be doing wrong?
  12. I am working on a script for a client of mine that will allow their clients to select photos to order and then will submit the order so that an admin can go back in and look at the order. I am stuck on one thing. I don't know how to go about creating an order id. I need something that is tied to each entry in the database. I thought about creating the order in the DB and then taking the created rowid and using it as the order id, but that doesn't seem efficient... any ideas? Thanks in advance
  13. I have a CURL app that makes a call to an external webpage on a different site and based upon certain URL params, this webpage will generate a PDF and then send the PDF back to the browser for download. Is there anyway to grab this PDF with CURL? I have tried it but CURL decodes the file and shows a bunch of weird characters on the screen. Thanks in advance! Dennis
  14. I have been banging my head against the wall for days on trying to get my web server optimal to my standards. My company is using a Java based CMS that calls for Tomcat to run on my ubuntu box which uses Apache and AJP Proxy to route everything. Is there anyway to configure my server to route requests for Tomcat through Tomcat and request for PHP through Apache alone?
  15. Sorry all it does is print_r the array you pass into it. updated code <?php class Deductible { function __construct() { mysql_connect('localhost', 'root', 'root')or die(mysql_error()); mysql_select_db('test')or die(mysql_error()); } function carrierSelect($carrier) { $results = mysql_query("SELECT DISTINCT manufacturer FROM portal_deductible WHERE carrier = '" . $carrier . "'"); while($row = mysql_fetch_object($results)) { $array[] = $row; } return $array; } function errorDisplay($msg) { echo '<pre>'; print_r($msg); echo '</pre>'; } } ?>
  16. Ah! Ok so that problem is fixed Now here is another one <?php require_once 'phplib.php'; $conn = new Deductible(); $manf = $conn->carrierSelect('att'); foreach($manf as $key => $val) { $conn->errorDisplay($manf); } ?> I can't get any results to return when using the following code... but if I do a $conn->errorDisplay($manf) I get everything back... any ideas?
  17. Before I begin, let me start off by saying that I am a newb when it comes to most things in using classes in PHP, so I apologize for the annoyance factor of simple questions Ok.. I am building out a class for a project I am working on and I am getting some weird errors and I have no idea how to solve them. <?php class Deductible { __construct() { mysql_connect('localhost', 'root', 'root')or die(mysql_error()); mysql_select_db('test')or die(mysql_error()); } function carrierSelect($carrier) { $results = mysql_query("SELECT DISTINCT manufacturer FROM portal_deductible WHERE carrier = '" . $carrier . "'"); return mysql_fetch_object($results); } } ?> Error Message: Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in /Applications/MAMP/htdocs/class/phplib.php on line 4 If I change my code to the following <?php class Deductible { function Deductible() { mysql_connect('localhost', 'root', 'root')or die(mysql_error()); mysql_select_db('test')or die(mysql_error()); } function carrierSelect($carrier) { $results = mysql_query("SELECT DISTINCT manufacturer FROM portal_deductible WHERE carrier = '" . $carrier . "'", $this->Deductible()); return mysql_fetch_object($results); } } ?> I now get this error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /Applications/MAMP/htdocs/class/phplib.php on line 9 Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /Applications/MAMP/htdocs/class/phplib.php on line 10 Any ideas on why this is happening? Thanks!
  18. This works perfect!!!!!! Thank you SOOO MUCH!
  19. I have the following function: function string_into_parts($text, $length=45) { $text = strval(trim($text)); $array = array(); $counter = 0; if(strlen($text) > $length) { for($i=0;$text[$length+$i]!=" ";$i++) { //line 67 if(!$text[$length+$i]) { //line 68 return $text; } } $array['firstHalf'] = trim(substr($text,0,$length+$i)); $array['secondHalf'] = trim(substr($text,$length+$i)); } else { $array['firstHalf'] = $text; $array['secondHalf'] = ''; } return $array; } but if you run it on a string that contains an individual number, IE: it broke into 2 pieces, the script fails and I receive the Uninitialized string offset error message. The script fails at lines 67 & 68. Anyone know why this could be failing? Thanks in advance!
  20. I have a function that takes a string and splits it up into two parts... well I keep running into the issue of Uninitialized String Offest: 52... but it only happens when the string is more than the specified length.. function string_into_parts($text, $length=45) { $text = trim($text); $array = array(); if(strlen($text) > $length) { for($i=0;$text[$length+$i]!=" ";$i++) { if(!$text[$length+$i]) { return $text; } } $array['firstHalf'] = trim(substr($text,0,$length+$i)); $array['secondHalf'] = trim(substr($text,$length+$i)); } else { $array['firstHalf'] = $text; $array['secondHalf'] = ''; } return $array; } Any help is much appreciated!!!!
  21. Thanks! I am a newbie when it comes to very complex SQL lol... how would i incorporate that into my query?
  22. I have a query that I am writing to convert a query statement into a JSON string, but when it runs it only returns 14 rows and a little bit of the 15th row... Any ideas on why this is? SELECT CONCAT("[", GROUP_CONCAT( CONCAT("{'rowid':'",rowid,"'"), CONCAT(",'carrier':'",carrier,"'"), CONCAT(",'manufacturer':'",manufacturer,"'"), CONCAT(",'model':'",model),"'}" ) ,"]") AS json FROM portal_deductible
  23. actually it was a logic problem with an else/if statement...
×
×
  • 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.