-
Posts
271 -
Joined
-
Last visited
Everything posted by blacknight
-
<br /> = new line
-
yea the code so we can give you an answer lol
-
use mime_content_type('php.gif') and run it aganst your allowed types this will stop corrupted gif files from being uploaded
-
how about the main page that calls the file and the template what does it look like
-
PHP/mySQL query skip repeated results in column header
blacknight replied to nullpoint81's topic in PHP Coding Help
really? i basicly modified a code i already use that works... in theory it should have prodiced an array like Array ( [55408] => Array ( [0] => Array ( [url] => a [name] => b ) [1] => Array ( [url] => c [name] => d ) ) [55412] => Array ( [0] => Array ( [url] => e [name] => f ) [1] => Array ( [url] => g [name] => h ) ) -
PHP/mySQL query skip repeated results in column header
blacknight replied to nullpoint81's topic in PHP Coding Help
try this code... $places = array(); while($row = mysql_fetch_array($qry_result)) { $places[$row[zip]]['url'] = $row[server_url]; $places[$row[zip]]['name'] = $row[name]; } echo "<table id=query_result align=left>"; foreach ($places as $place => $d) { echo "<tr>"; echo "<th><b>$place</b></th>"; echo "</tr>"; foreach ($d as $n => $r) { echo "<tr>"; echo "<td><a href=$r[url] rel=ajaxDiv>$r[name]</a></td>"; echo "</tr>"; } } should have the result your looking for -
if your paranoid run passwords and usernames thru a text matcher for characters you deam not usable like ( ) = ` these are mostly used in sql queries and if used kick the user back with an error
-
same idea basicly $query = 'INSERT INTO `yourtable` VALUES '; foreach ($arr as $value => $e) { $query .= "("; foreach ($e as $b => $a) { $query .= "'".$a."',"; } $query = preg_replace('/,$/', '', $query); $query .= "), "; } $query = preg_replace('/, $/', ';', $query); echo $query.'<br>';
-
yes a while loop would achieve what you want
-
for what you want .. i think you need a multi dementional array... try $arr = array(array('mikel', '17', 'cambodia', '50kgs', '5 feet'), array('anna', '21', 'peru', '45kgs', '6 feet')); foreach ($arr as $value => $e) { foreach ($e as $b => $a) { echo $a.'<br>'; } } to a further extent $names = array('name','Age','address','weight','height'); $arr = array(array('mikel', '17', 'cambodia', '50kgs', '5 feet'), array('anna', '21', 'peru', '45kgs', '6 feet')); foreach ($arr as $value => $e) { foreach ($e as $b => $a) { echo $names[$b] .' - '.$a.'<br>'; } echo '<br>'; }
-
even so hes tryen to pull the data from the table query not the result ... $result = MYSQL_QUERY($myselect) or die('Query failed: ' . mysql_error() . "<br />\n$myselect"); if (mysql_num_rows($myselect)==0) { should be $result = MYSQL_QUERY($myselect) or die('Query failed: ' . mysql_error() . "<br />\n$myselect"); if (mysql_num_rows($result)==0) { and while ($get_row=mysql_fetch_array($myselect)) { should be while ($get_row=mysql_fetch_array($result)) {
-
Plugins theory, how can I allow people to add plugins to my script?
blacknight replied to MrGary's topic in PHP Coding Help
this is getten slightly off topic .... but as a final point if im so wrong wht does phpbba nd smf use the global command in there functions in there class files... @MrGary some things i have found placing hooks at the start mid and end of a script gives more options for a user also look into event hooks but thats a larger can of worms.. -
How to not display picture icon if no picture in mysql database
blacknight replied to frank_solo's topic in PHP Coding Help
replace <img src=user/". $row['imageurl1'] ." width='50'> with ".(isset($row['imageurl1'] ) ? "<img src=user/". $row['imageurl1'] ." width='50'>" : '' )." -
i think there is a way to do this in jquery but i cant remember how...
-
use define ex define ('MY_DATABASE','mydatabasename'); thern call MY_DATABASE like you would any other var with a $ place this in a file thats allways called at the begining and any scriptthats included after can allways get this info..
-
i have to ask why..... json code is normaly passed so that you run it thru your webpage and display the info the average user wont see it ....
-
Plugins theory, how can I allow people to add plugins to my script?
blacknight replied to MrGary's topic in PHP Coding Help
yes our frame work uses reg global so addons can use our fw not there oen makes them smaller lol but thats the basic idea -
Plugins theory, how can I allow people to add plugins to my script?
blacknight replied to MrGary's topic in PHP Coding Help
make a folder called plugins each plugin has to have a class in it and have code to function with your code here i sm y example system we now use in wowroster simple mode class guild_rep { var $members_list_select; var $members_list_table; var $members_list_where = array(); var $members_list_fields = array(); /* * __construct * this is there the veriables for the addons are * set in the plugin these are unique to each addon * * contact the addon author is you have a sugestion * as to where plugin code should occure or use there descression */ public function __construct() { global $roster; $this->members_list_select = '`rep`.`curr_rep`, `rep`.`max_rep`, `rep`.`AtWar`, `rep`.`Standing`, `rep`.`name` AS \'repname\', IF( `rep`.`Standing` IS NULL OR `rep`.`Standing` = \'\', 1, 0 ) AS `repisnull`, '; $this->members_list_table = 'LEFT JOIN `'.$roster->db->table('reputation').'` AS rep ON `members`.`member_id` = `rep`.`member_id` '; $this->members_list_where['guild_rep'] = "`rep`.`name` = '".$roster->data['guild_name']."' OR `rep`.`name` IS NULL"; $this->members_list_fields['guild_rep'] = array ( 'lang_field' => 'reputation', 'value' => 'guild_rep_function::guild_rep', 'order' => array( '`rep`.`max_rep` ASC','`rep`.`curr_rep` ASC' ), 'order_d' => array( '`rep`.`max_rep` DESC','`rep`.`curr_rep` DESC' ), 'filter' => false, 'display' => 5 ); } } and to call said files function _initPlugins() { global $roster, $addon; $addons = $roster->addon_data; if( !empty($addons) ) { foreach( $addons as $addon_name => $addonx ) { $dirx = ROSTER_ADDONS . $addonx['basename'] . DIR_SEP . 'inc' . DIR_SEP . 'plugins' . DIR_SEP; if (is_dir($dirx)) { $dir = opendir ($dirx); while (($file = readdir($dir)) !== false) { if (strpos($file, '.php',1)) { $info = pathinfo($file); $file_name = basename($file,'.'.$info['extension']); list($reqaddon, $scope, $name) = explode('-',$file_name); if (isset($roster->plugin_data[$name]) && $roster->plugin_data[$name]['active'] == '1') { if ($scope == $roster->scope && $reqaddon == $addon['basename']) { require($dirx . $file); $addonstuff = new $name; $this->members_list_select .= $addonstuff->members_list_select; $this->members_list_table .= $addonstuff->members_list_table; if (isset($addonstuff->members_list_where)) { $this->members_list_where[] = $addonstuff->members_list_where; } $this->members_list_fields[] = $addonstuff->members_list_fields; unset($addonstuff); } } } } } } } return true; } this loops the dir for each file in this case plugins for an addon but can be changed to just incluse any plugin happy coding -
$data = 'a:1:{s:9:"calendars";a:1:{i:1;a:4:{s:12:"calendarName";s:21:"Availability Calendar";s:12:"calendarJson";s:59:"{"year2011":{"month12":{"day25":"booked","day6":"booked"}}}";s:11:"dateCreated";i:1324333825;s:12:"dateModified";i:1324333825;}}}'; $x = @unserialize($data); echo '<pre>'; print_r($x); $a = json_decode($x['calendars']['1']['calendarJson'],true); print_r($a); this worked on my server unserialize is php 4.3 i think
-
insert a space into a string IF there isnt a space already
blacknight replied to mackin's topic in PHP Coding Help
use wordwrap($str, 3, " ", true) $str being your postalcode 3 being every 3 characters im canadian so this is our standard but it can be changed to any number and it does not leave a traling space ither -
this means in your database table there is a row with the primary id of 6 allready
-
have you restarted the web server? is this the MAIN config file for your server?
-
standard cookie use setcookie('user',$user,(time()+60*60*24*30) ); this makes the cookie last for 30 days $_COOKIE['user'] in your code to call the cookie
-
why wouldent you use a dropdown insted? or $id_nums = implode("' OR `nationality` = '", $_POST['natBox']); $query = "SELECT * FROM user_criteria WHERE (age BETWEEN '".$ageFr."' AND '".$ageTo."') AND `nationality` = '".$id_nums."'";
-
Limiting number of post's per user a dy
blacknight replied to RalphLeMouf's topic in PHP Coding Help
because thats your issue and NOW() isnot a php function ..... in my database i use time() spits out in seconds that way (60*60*24) = 1 day time()-(60*60*24) = yesterday this time