Jump to content

atyndall

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

atyndall's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. *bump* hello? anyone with any suggestions???
  2. Happy now? <?php $image_info = array( 'image' => '500150bg.gif' ); function GetWPData ($columnname, $limit) { $q = mysql_query("SELECT `post_date`, `post_title` FROM `wp_posts` WHERE (post_type = 'post' AND post_status = 'publish') ORDER BY `wp_posts`.`post_date` DESC LIMIT 0,$limit"); $num = mysql_numrows($q); $i=0; while ($i < $num) { $rows = mysql_result($q,$i,"$columnname"); $array["$i"] = $rows; $i++; } return $array; } function RearrangeDate ($var, $format) { $i=0; foreach ($var as $td) { $date = substr($td, 0, 10); $y = substr($date, 0, 4); $m = substr($date, 5, 2); $d = substr($date, 8, 2); $array["$i"] = $format; $i++; } return $array; } function RearrangeTime ($var, $format) { $i=0; foreach ($var as $td) { $time = substr($td, 11, ; $h = substr($time, 0, 2); $m = substr($time, 3, 2); $s = substr($time, 6, 2); $array["$i"] = $format; $i++; } return $array; } function MakeArray () { $i=0; while ($i < $num) { $text["$i"] = "$td_format[$i] - $p_title[$i]"; $i++; } return $text; } // ########## START OPTIONS ########## // Time Options $h = $lt[tm_hour]; // DON'T EDIT $m = $lt[tm_min]; // DON'T EDIT $s = $lt[tm_sec]; // DON'T EDIT $t = "$h:$m"; // Local/Post Time Format, $h = hours, $m = minutes, $s = seconds. $tz = 'Australia/Perth'; // Your nearest timezone chosen from the list at www.php.net/timezones date_default_timezone_set("$tz"); $lt = localtime(time(), true); // DON'T EDIT $ld_format = "d/m/Y"; // Local Date Format, d = days, m = months, Y = years. $d = date($ld_format); // DON'T EDIT $pd_format = "$d/$m/$y"; // Post Date Format, $d = day, $m = month, $y = year. $td_format = "$d $t"; // Time-Date Format, $d = date, $t = time. // MySQL Options // Display Options $num = 4; // Number of Wordpress Articles to show. //$text_format = ''; // ########## END OPTIONS ########## mysql_connect($server,$username,$password); @mysql_select_db("$db") or die('Unable to select database'); $p_d = RearrangeDate(GetWPData('post_date',$num),$pd_format); $p_t = RearrangeTime(GetWPData('post_date',$num),$t); $p_title = GetWPData('post_title',$num); $text = MakeArray(); mysql_close(); $image_text = array( array( 'x' => 17, 'y' => 49, 'color' => array(0, 0, 0), 'font' => -5, 'text' => "Latest Articles (as of $td_format):" ), array( 'x' => 17, 'y' => 65, 'color' => array(0, 0, 0), 'font' => -4, 'text' => $text[0] ), array( 'x' => 17, 'y' => 80, 'color' => array(0, 0, 0), 'font' => -4, 'text' => $text[1] ), array( 'x' => 17, 'y' => 95, 'color' => array(0, 0, 0), 'font' => -4, 'text' => $text[2] ), array( 'x' => 17, 'y' => 110, 'color' => array(0, 0, 0), 'font' => -4, 'text' => $text[3] ), array( 'x' => 17, 'y' => 124, 'color' => array(0, 0, 0), 'font' => -2, 'text' => "All times are $tz time." ) ); require('dynamic_gd_image.php'); ?> Can I now please have someone actually answer my question and not comment on my indenting skills
  3. it was indented but for some reason the forum software reset the indentions.
  4. And to remove any error messages you may encounter put: <?php ini_set('display_errors', False); //code... ?> (on the first line after your <?php tag)
  5. This is my code: <?php $image_info = array( 'image' => '500150bg.gif' ); function GetWPData ($columnname, $limit) { $q = mysql_query("SELECT `post_date`, `post_title` FROM `wp_posts` WHERE (post_type = 'post' AND post_status = 'publish') ORDER BY `wp_posts`.`post_date` DESC LIMIT 0,$limit"); $num = mysql_numrows($q); $i=0; while ($i < $num) { $rows = mysql_result($q,$i,"$columnname"); $array["$i"] = $rows; $i++; } return $array; } function RearrangeDate ($var, $format) { $i=0; foreach ($var as $td) { $date = substr($td, 0, 10); $y = substr($date, 0, 4); $m = substr($date, 5, 2); $d = substr($date, 8, 2); $array["$i"] = $format; $i++; } return $array; } function RearrangeTime ($var, $format) { $i=0; foreach ($var as $td) { $time = substr($td, 11, ; $h = substr($time, 0, 2); $m = substr($time, 3, 2); $s = substr($time, 6, 2); $array["$i"] = $format; $i++; } return $array; } function MakeArray () { $i=0; while ($i < $num) { $text["$i"] = $td_format["$i"].' - '. $p_title["$i"]; $i++; } return $text; } // ########## START OPTIONS ########## // Time Options $h = $lt[tm_hour]; // DON'T EDIT $m = $lt[tm_min]; // DON'T EDIT $s = $lt[tm_sec]; // DON'T EDIT $t = "$h:$m"; // Local/Post Time Format, $h = hours, $m = minutes, $s = seconds. $tz = '__REMOVED__'; // Your nearest timezone chosen from the list at www.php.net/timezones date_default_timezone_set("$tz"); $lt = localtime(time(), true); // DON'T EDIT $ld_format = "d/m/Y"; // Local Date Format, d = days, m = months, Y = years. $d = date($ld_format); // DON'T EDIT $pd_format = "$d/$m/$y"; // Post Date Format, $d = day, $m = month, $y = year. $td_format = "$d $t"; // Time-Date Format, $d = date, $t = time. // MySQL Options $username = '__REMOVED__'; // Database Username. $password = '__REMOVED__'; // Database Password. $server = '__REMOVED__'; // Database server (most likely localhost). $db = '__REMOVED__'; // Database Name. // Display Options $num = 4; // Number of Wordpress Articles to show. // ########## END OPTIONS ########## mysql_connect($server,$username,$password); @mysql_select_db("$db") or die('Unable to select database'); $p_d = RearrangeDate(GetWPData('post_date',$num),$pd_format); $p_t = RearrangeTime(GetWPData('post_date',$num),$t); $p_title = GetWPData('post_title',$num); $text = MakeArray(); //mysql_close(); $image_text = array( array( 'x' => 17, 'y' => 49, 'color' => array(0, 0, 0), 'font' => -5, 'text' => "Latest Articles (as of $td_format):" ), array( 'x' => 17, 'y' => 65, 'color' => array(0, 0, 0), 'font' => -4, 'text' => $text[0] ), array( 'x' => 17, 'y' => 80, 'color' => array(0, 0, 0), 'font' => -4, 'text' => $text[1] ), array( 'x' => 17, 'y' => 95, 'color' => array(0, 0, 0), 'font' => -4, 'text' => $text[2] ), array( 'x' => 17, 'y' => 110, 'color' => array(0, 0, 0), 'font' => -4, 'text' => $text[3] ), array( 'x' => 17, 'y' => 124, 'color' => array(0, 0, 0), 'font' => -2, 'text' => "All times are $tz time." ) ); require('dynamic_gd_image.php'); ?> It returns a result like this: When it should return a result like this: Can anyone see what is wrong with my code? Any problems than need to be fixd, any ways the code can be made more efficient? Thankyou, atyndall93 (AKA Mr. PHP Newbie)
  6. yes, i have checked and my username and password are correct.
  7. But I am using a password, thats whats weird, ive just removed it (for obvious reasons) EDIT: I tried what you said, didnt change anything exact same. EDIT: And when I enter in a random non-existant username but same password I get this:
  8. OK, this is the relevant portion script: 7. $username = '__'; // MySQL Database Username. 8. $password = '__'; // MySQL Database Password. 9. $server = '__'; // MySQL Database server (most likely localhost). 10. $db = '__'; // MySQL Database Name. 11. $num = 4; // Number of Wordpress Articles to show. 12. $tz = '__'; // Your Timezone written using the list at http://php.net/timezones 13. 14. 15. mysql_connect($server,$username,$password); 16. @mysql_select_db("$db") or die('Unable to select database'); 17. 18. 19. function GetWPData ($columnname, $limit) { 20. $q = mysql_query("SELECT `post_date`, `post_title` FROM `wp_posts` WHERE (post_type = 'post' AND post_status = 'publish') ORDER BY `wp_posts`.`post_date` DESC LIMIT 0,$limit"); 21. $num = mysql_numrows($q); 22. $i=0; 23. while ($i < $num) { 24. $rows = mysql_result($q,$i,"$columnname"); 25. $array["$i"] = $rows; 26. $i++; 27. } 28. return $array; 29. } 30. 31. function RearrangeDate ($var) { 32. $i=0; 33. foreach ($var as $td) { 34. $date = substr($td, 0, 10); 35. $y = substr($date, 0, 4); 36. $M = substr($date, 5, 2); 37. $d = substr($date, 8, 2); 38. 39. $format = "$d/$M/$y"; 40. // $d = day, $M = month, $y = year. 41. 42. $array["$i"] = $format; 43. $i++; 44. } 45. return $array; 46. } 47. 48. function RearrangeTime ($var) { 49. $i=0; 50. foreach ($var as $td) { 51. $time = substr($td, 11, ; 52. $h = substr($time, 0, 2); 53. $m = substr($time, 3, 2); 54. $s = substr($time, 6, 2); 55. 56. $format = "$h:$m"; 57. // $h = hours, $m = minutes, $s = seconds. 58. 59. $array["$i"] = $format; 60. $i++; 61. } 62. return $array; 63. } 64. 65. function StringTogether ($d_arr, $t_arr, $title_arr) { 66. $i=0; 67. while ($i < $num) { 68. $d = $d_arr["$i"]; 69. $t = $t_arr["$i"]; 70. $title = $title_arr["$i"]; 71. 72. $format = "$d $t - $title"; 73. // $d = date, $t = time, $title = title 74. 75. $array["$i"] = $format; 76. $i++; 77. } 78. $text = implode('<br>', $array); 79. return $text; 80. } 81. 82. mysql_close(); 83. 84. $p_d = RearrangeDate(GetWPData('post_date',$num)); 85. $p_t = RearrangeTime(GetWPData('post_date',$num)); 86. $p_title = GetWPData('post_title',$num); 87. $text = StringTogether($p_d, $p_t, $p_title); 88. 89. date_default_timezone_set("$tz"); 90. $lt = localtime(time(), true); 91. $h = $localtime[tm_hour]; 92. $m = $localtime[tm_min]; 93. $s = $localtime[tm_sec]; 94. $ld = date($ldformat); 95. 96. $lt_format = "$h:$m"; // Local Time Format 97. // $h = hours, $m = minutes, $s = seconds. 98. $ld_format = "d/m/Y"; // Local Date Format 99. // d = days, m = months, Y = years. 100. $td_format = "$ld $lt"; // Time-Date Format 101. // $ld = date, $lt = time. 102. 103. $td=$td_format; when I run it I get the following errors: What needs fixing in my script to get everything working? The MySQL username and password were entered and correctly spelt despite what the error messages say and have only been removed for security reasons. Can anyone help this newbie programmer? Thanks atyndall93
×
×
  • 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.