Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. Correct. I prefer to use mixed quotes so as not to escape the character i.e $id = 1; $string = "<a href='index.php?pageId=".$id."'></a>"; print $string;
  2. if you use the mysql MAX() function you have to include a GROUP BY statement. i.e. SELECT MAX(fieldName) FROM table GROUP BY id ORDER BY id DESC
  3. Your syntax is really bad. Are you new to PHP? You do not include script tags <? ?> within a script. You also need to escape quotes or it will see it as the end of a string. echo "<a rel=\"lightbox\" href=\"images/products/".$ID."one.jpg\"><img Clean up the rest of your code.
  4. If the query is incorrect the script will terminate. If OK the results of the query are in $forumrow. Apply to the rest of your logic. if(!$forumresult = mysql_query($forumsql)) { die(mysql_error()); exit(); } $forumrow = mysql_fetch_assoc($forumresult);
  5. Bad syntax! Should be: $filename = "/images/products/".$ID."one.jpg";
  6. check the query is correct. You should not continue to process the script if the query produces an error which is what you are doing. You need to handle errors. A simple method is: if(!$result = mysql_query("SELECT ...")) { die(mysql_error()); }
  7. Yes. Heres another method. function breadPath($path,$pathTxt) { $pathArray = explode("|",$path); $pathTxtArray = explode('|',$pathTxt); $link = array(); for($x = 1; $x < count($pathTxtArray); $x++) { $link[] = '<a href="index.php?pageId='.$pathArray[$x].'">'.$pathTxtArray[$x].'</a>'; } return implode(" >> ",$link); } // page path: Home|Page 1|Sub Page 1 // page id path: 0|1|69 $path = "0|1|69"; $pathTxt = "Home|Page 1|Sub Page 1"; echo breadPath($path,$pathTxt); I would store the pages in a database table with the following fields: pages ------ pageId parentId title path pathTxt So if I am on pageId 69 I can get the record for pageId 69. The path may be 0|1|69 (its parent being 1) and the pathText would be Home|Page 1|Sub Page 1. Run the values through the function. So the table records may look like: 0 , -1 , Home , 0 , Home 1 , 0 , Page 1 , 0|1, Home|Page 1 69, 1, Sub Page 1, 0|1|69, Home|Page 1|Sub Page 1 Get it?
  8. Simplify the function i.e. function breadPath($path) { $crumb = array(); foreach($path as $id => $val) { $crumb[] = "<a href='index.php".(($id !=0) ? "?pageId=".$id."" : "")."'>".$val."</a>"; } return implode(" >> ", $crumb); } $path = array("Home",5 => "Page 1", 6 => "Page 2"); echo breadPath($path);
  9. Doesnt do anything when these dates are checked and you submit the form. Why arent you ordering the results returned by the database query i.e? ORDER BY end_date DESC
  10. if(file_exists($pathToFile)) { // display the image }
  11. This would be much better using Javascript event handling functions or if a database is in use then AJAX.
  12. All the stories will display but if they dont have a summary then it simply wont display a summary. Im confused at this post.
  13. PHP can login to your email server and read the messages. It could extract the Ext part of the message subject and then store that into a database before moving onto the next message.
  14. Mail headers are part of the message construct so that a mail agent can display where the message has come from, what type of content it is, the reply address, etc (you must have seen an email in Microsoft Outlooks inbox). Without the headers you may get errors when using the mail() function.
  15. These methods are designed to print data to the screen $this->getMessage(); $this->getCode(); etc.. Take a look at the class construct: http://uk2.php.net/manual/en/class.exception.php You do not need to store $this->message as it is already set in the Exception class You can access it directly with $this->message in your inherited class.
  16. Count the number of records. Divide by the number of records to show on each page to get the number of pages: use ceil(); Use the array offsets to determine which value to start at and end with for each page. The URL parameter to determine the page could be the starting offset. Work with that.
  17. Your $StaffName variable is created inside a loop from a DB query meaning that if the query produces 0 results then the variable is not defined. If you are returning a variable in a function you should always define it near the top of the function: $StaffName = ""; // run query return $StaffName;
  18. Run the script standalone rather than using the IMG SRC tag i.e. www.yourdomain.com/captchascript.php Remove all error supressing @ in the script. Do you get any errors? It should just display an image. Have you moved the site to another server. You need the GD libraries for this to work.
  19. Any form of external data mining is going to take time. The response speed of the external site is a major factor. For this job I would prefer to user CURL rather than fopen()/stream_get_contents() or file_get_contents().
  20. The & is passing the variable by reference so its value is changed outside the scope of the function i.e function add(&$x) { $x = $x+1; } $x = 1; add($x); print $x; // should print 2
  21. you can do this beacause the output of the php source code is a gif image: header("Content-type: image/gif"); What isnt working? Is this just a CAPTCHA image?
  22. Try curl_setopt($ch, CURLOPT_USERPWD,"{$usrnm}:{$pswrd}");
  23. You dont need the zips in the companies table as you have a relationship using the ZipsToCompany table with the foreign keys comp_id and zip_id. The z in the query is a table alias so you can reference the fields in each table so: SELECT a.field1, b.field2 FROM tableA a, tableB b WHERE a.primaryKey=b.foreignKey
  24. SELECT ztc.company_id FROM zip z LEFT JOIN zip_to_company ztc ON (z.zip_id = ztc.zip_id AND z.zip='12345') If your a db novice you are best doing some swatting up first as this is not really beginners stuff. Sorry.
  25. Looks pretty straightforward. You may want to check that values have been entered before running them through functions // check to make sure data has been entered if(strlen(trim($_POST['login'])) && strlen(trim($_POST['password']))) { }
×
×
  • 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.