PHP - Internet Radio Array Problem
Well this is my first time using icecast and I am a little lost. I have these two (three in a way) files that are all linked in a way.
index.php > cast_info.php > status.xsl so here are the files: index.php Code: [Select] <?php require_once("cast_info.php"); ?> <table> <tr> <th colspan="2">Stats For Icecast Server: <?php echo $radio_info['title']; ?></th> </tr> <?php foreach($radio_info as $title => $data) { switch($title) { case 'now_playing' : ?><tr> <td><b><?php echo $title; ?></b></td> <td><?php echo $data['artist']; ?><br /> <?php echo $data['track']; ?> </td> </tr><?php break; case 'title' : //skip break; default : ?><tr> <td><?php echo $title; ?></td> <td><?php echo $data; ?></td> </tr><?php break; } } ?> </table> cast_info.php Code: [Select] <?php /* * Script Configurations */ $SERVER = 'http://grimradio.com:8000'; //$SERVER = 'http://localhost:8000'; //enter the URL to your Icecast server $STATS_FILE = '/status.xsl'; //enter the path to your status.xsl file (leave blank unless u know its different) //////////////////////////////////// END OF CONFIGURATION ----- DO NOT EDIT BELOW THIS LINE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ //get statistics file contents $fp = fopen($SERVER.$STATS_FILE,'r'); if(!$fp) { //error connecting to server! die("Unable to connect to Icecast server."); } $stats_file_contents = ''; while(!feof($fp)) { $stats_file_contents .= fread($fp,1024); } fclose($fp); //create array to store results for later usage $radio_info = array(); $radio_info['server'] = $SERVER; $radio_info['title'] = ''; $radio_info['description'] = ''; $radio_info['content_type'] = ''; $radio_info['mount_start'] = ''; $radio_info['bit_rate'] = ''; $radio_info['listeners'] = ''; $radio_info['most_listeners'] = ''; $radio_info['genre'] = ''; $radio_info['url'] = ''; $radio_info['now_playing'] = array(); $radio_info['now_playing']['artist'] = ''; $radio_info['now_playing']['track'] = ''; $temp = array(); //format results into array $search_for = "<td\s[^>]*class=\"streamdata\">(.*)<\/td>"; $search_td = array('<td class="streamdata">','</td>'); if(preg_match_all("/$search_for/siU",$stats_file_contents,$matches)) { foreach($matches[0] as $match) { $to_push = str_replace($search_td,'',$match); $to_push = trim($to_push); array_push($temp,$to_push); } } //build final array from temp array $radio_info['title'] = $temp[0]; $radio_info['description'] = $temp[1]; $radio_info['content_type'] = $temp[2]; $radio_info['mount_start'] = $temp[3]; $radio_info['bit_rate'] = $temp[4]; $radio_info['listeners'] = $temp[5]; $radio_info['most_listeners'] = $temp[6]; $radio_info['genre'] = $temp[7]; $radio_info['url'] = $temp[8]; //format now playing $now_playing = explode(" - ",$temp[9]); $radio_info['now_playing']['artist'] = $now_playing[0]; $radio_info['now_playing']['track'] = $now_playing[1]; ?> status.xsl Code: [Select] <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" > <xsl:output omit-xml-declaration="no" method="html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes" encoding="UTF-8" /> <xsl:template match = "/icestats" > <html> <head> <title>Icecast Streaming Media Server</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"> <h2>Icecast2 Status</h2> <br /> <!--index header menu --> <div class="roundcont"> <div class="roundtop"> <img src="/corner_topleft.jpg" class="corner" style="display: none" /> </div> <table border="0" width="100%" id="table1" cellspacing="0" cellpadding="4"> <tr> <td bgcolor="#656565"> <a class="nav" href="admin/">Administration</a> <a class="nav" href="status.xsl">Server Status</a> <a class="nav" href="server_version.xsl">Version</a></td> </tr> </table> <div class="roundbottom"> <img src="/corner_bottomleft.jpg" class="corner" style="display: none" /> </div> </div> <br /> <br /> <!--end index header menu --> <!--mount point stats--> <xsl:for-each select="source"> <xsl:choose> <xsl:when test="listeners"> <div class="roundcont"> <div class="roundtop"> <img src="/corner_topleft.jpg" class="corner" style="display: none" /> </div> <div class="newscontent"> <div class="streamheader"> <table cellspacing="0" cellpadding="0"> <colgroup align="left" /> <colgroup align="right" width="300" /> <tr> <td><h3>Mount Point <xsl:value-of select="@mount" /></h3></td> <xsl:choose> <xsl:when test="authenticator"> <td align="right"><a class="auth" href="/auth.xsl">Login</a></td> </xsl:when> <xsl:otherwise> <td align="right"> <a href="{@mount}.m3u">M3U</a> <a href="{@mount}.xspf">XSPF</a></td> </xsl:otherwise> </xsl:choose> </tr></table> </div> <table border="0" cellpadding="4"> <xsl:if test="server_name"> <tr><td>Stream Title:</td><td class="streamdata"> <xsl:value-of select="server_name" /></td></tr> </xsl:if> <xsl:if test="server_description"> <tr><td>Stream Description:</td><td class="streamdata"> <xsl:value-of select="server_description" /></td></tr> </xsl:if> <xsl:if test="server_type"> <tr><td>Content Type:</td><td class="streamdata"><xsl:value-of select="server_type" /></td></tr> </xsl:if> <xsl:if test="stream_start"> <tr><td>Mount started:</td><td class="streamdata"><xsl:value-of select="stream_start" /></td></tr> </xsl:if> <xsl:if test="bitrate"> <tr><td>Bitrate:</td><td class="streamdata"> <xsl:value-of select="bitrate" /></td></tr> </xsl:if> <xsl:if test="quality"> <tr><td>Quality:</td><td class="streamdata"> <xsl:value-of select="quality" /></td></tr> </xsl:if> <xsl:if test="video_quality"> <tr><td>Video Quality:</td><td class="streamdata"> <xsl:value-of select="video_quality" /></td></tr> </xsl:if> <xsl:if test="frame_size"> <tr><td>Framesize:</td><td class="streamdata"> <xsl:value-of select="frame_size" /></td></tr> </xsl:if> <xsl:if test="frame_rate"> <tr><td>Framerate:</td><td class="streamdata"> <xsl:value-of select="frame_rate" /></td></tr> </xsl:if> <xsl:if test="listeners"> <tr><td>Current Listeners:</td><td class="streamdata"> <xsl:value-of select="listeners" /></td></tr> </xsl:if> <xsl:if test="listener_peak"> <tr><td>Peak Listeners:</td><td class="streamdata"> <xsl:value-of select="listener_peak" /></td></tr> </xsl:if> <xsl:if test="genre"> <tr><td>Stream Gen </td><td class="streamdata"> <xsl:value-of select="genre" /></td></tr> </xsl:if> <xsl:if test="server_url"> <tr><td>Stream URL:</td><td class="streamdata"> <a target="_blank" href="{server_url}"><xsl:value-of select="server_url" /></a></td></tr> </xsl:if> <tr><td>Current Song:</td><td class="streamdata"> <xsl:if test="artist"><xsl:value-of select="artist" /> - </xsl:if><xsl:value-of select="title" /></td></tr> </table> </div> <div class="roundbottom"> <img src="/corner_bottomleft.jpg" class="corner" style="display: none" /> </div> </div> <br /> <br /> </xsl:when> <xsl:otherwise> <h3><xsl:value-of select="@mount" /> - Not Connected</h3> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:text disable-output-escaping="yes">&</xsl:text>nbsp; <div class="poster">Support icecast development at <a class="nav" target="_blank" href="http://www.icecast.org">www.icecast.org</a></div> </body> </html> </xsl:template> </xsl:stylesheet> now what the problem is, is that it won't display the "now playing" info. not sure exactly where the error might be, but I am sure it has to do with that array. you can view what does display here http://grimradio.com/ Similar TutorialsWhy wont my radio array show the value that was selected. If a user select a radio then the value should be printed. But it should print the question id then the choice that was chosen for that question id. Code: [Select] <?php $gender = $_POST["choice"]; $que_ID = $_POST["Que_ID"]; foreach ($gender as $key => $value) { echo $key." - ".$value."";} ?> Code: [Select] $intNum = 1; $intnumber = 1; while( $info = mysql_fetch_array( $sqll )){ echo "<input type='hidden' name=\"Que_ID\" value=\"{$info['Que_ID']}\" /> "; echo " $intNum, {$info['Que_Question']} <br />\n"; $intNum++; for ($i =1; $i < 5; $i++) { echo "<input type=\"Radio\" name=\"choice[{$info['Que_ID']}][]\" />{$info['Que_Choice'.$i]}<br />\n"; $intnumber++; Hi, I have 2 radio button's within a table and need to pass this array. All other rows within my table can be sent as array's and captured using $_POST['field_name'][$ROW 1 value etc]. However for radio buttons this doesn't work. As an example, a standard textbox I can send an array using the following: echo "<td width='33%'><input type='Textbox' width='100%' id='test' name='test[]' value='" .$row['test']. "'></td>"; I can then capture it using: $test = $_POST['test'][$iLine]; This works, no problem, however for radio buttons, I can't use a static array name, as presumably it dumps all rows into the array, if I do this, only the last row has a checked button, hence I need to use the following (where $checked includes the logic to decide whether the button should be checked or not, this works correctly): echo "<input type='radio' name='".$row['venue_id']."[]' value='1'".$checked."/>P1" echo "<input type='radio' name='".$row['venue_id']."[]' value='0'".$checked2." />P2"; I tried using the following: var_dump($_POST[$row]['game_id'][$iLine]); But this just returns a null value. Any ideas? I have worked on a while loop as a radio and this dispalys well and Now I am trying to post this to the next page. But kind of stuck. This is my while loop for the form Code: [Select] $intNum = 1; $intnumber = 1; while( $info = mysql_fetch_array( $sqll )){ echo "<input type='hidden' name=\"Que_ID\" value=\"{$info['Que_ID']}\" /> "; echo " $intNum, {$info['Que_Question']} <br />\n"; $intNum++; for ($i =1; $i < 5; $i++) { echo "<input type=\"Radio\" name=\"choice[{$intnumber}]\" />{$info['Que_Choice'.$i]}<br />\n"; $intnumber++; } } ?> <input type="submit" name="submit" value="submit"/> </form> </body> </html> Now in order for me to post this to the next page, can I do something like Code: [Select] if (isset($_POST['Submit1'])) { $qu=$_POST[Que_ID]; $choi=$_POST[choice]; for($i=1; $1=5; i++) echo $qu. $choi; this is just my guess. I want the que_ID to display four choice for each question ID. so it would be Question ID=2(choice1=selected, choice2=notselected, choice3=not selected, chocie4=not selected) and this would be repeated to the next question ID. So far I can notice that my chociename are added by one(choice1, choice2,choice3,choice4,choice5,choice6,choice7,choice8,choice8......) so my post for loop will not work work as my choices goes up to more then 5. Well, my page contains a URL like file.php?userid=1&pass=passwordhashblablabla. I try to open the page on opera, mozilla, safari, google chrome and so browsers and it works fine. I get the message that id/pw match and user has logged in successfully. However, when I go to THE SAME url on IE, i get message that id/pw do not match. URL is still the same, history is cleaned... Thanks in advance. Hi, as usual there is a problem ONLY with one browser... IE (any version). Please check the webpage & notice the space between the Header buttons. I can't find the PROBLEM!!! Please help!! Thanks in advance.. Hello All,
I'm kinda new to PHP and web development and I seem to have a very wierd problem which is driving me nuts (for the last 2 days)...so I'd appreciate any and all help in getting it resolved.
Okay, so here's the problem:
In the code below, I used to have just the first statement below...which essentially accepted input as a textbox for a text field named qty_pkg (in the underlying MySQL table)...and that used to work just fine.
So then I decided to change the input type for that field to be a radio button, accepting one of two choices i.e. "UoM" or "Qty", and therefore I added the remainder of the code, whilst also commenting/remarking out the first statement.
What happens (when I added the radiobutton-related code) is that control no longer goes into the TRUE portion/logic of the "if ( !empty($_POST))" condition-check, but rather, it seems to go into the "ELSE/FALSE" portion of that conditional check. However, a record does get added to my table, even though I do not have an "INSERT INTO..." clause in the ELSE porition of that check. Also, what gets displayed on screen is as follows:
------------------------------------------------------------------------------------------------------------------------------------
Array()
There's something wrong somewhere!!!
Array()
------------------------------------------------------------------------------------------------------------------------------------
Now, if/when I comment/remark the radiobutton-related code, the "if ( !empty($_POST))" logic seems to work fine and the following is displayed on screen (which is what I expect):
------------------------------------------------------------------------------------------------------------------------------------
Array ( [datepicker] => 10/30/2014 [store_id] => 48 [new_store_name] => [item_id] => 5 [new_item_name] => [pkg_of] => 1 [price] => 1 [flyer_page] => 1 [limited_time_sale] => Array ( [0] => fri [1] => sat ) [nos_to_purchase] => 1 [create-and-add-more] => Create and Add More ) Notice: Undefined index: qty_pkg in /var/www/create.php on line 54 Array ( [0] => Array ( [item_id] => 5 [0] => 5 [item_name] => BD Cheese Strings [1] => BD Cheese Strings [section_id] => 7 [2] => 7 ) ) ------------------------------------------------------------------------------------------------------------------------------------ The other wierd thing is that if/when I now uncomment the first statement (which used to work just fine before) the "if ( !empty($_POST))" logic no longer seems to work the way it used to. Does/can someone see something wrong with my code somewhere? <!-- <?php echo standardInputField('Qty / Pkg', 'qty_pkg', $qty_pkg, $errors); ?> --> <div class="control-group"> <label class="control-label">Priced by:</label> <div class="priced-by-radio-container"> <div class="pb-radiobuttons-container"> <label class="indent-to-the-left"> <input class='priced-by-radiobutton' type='radio' name='qty_pkg' value='UoM' $pb1> <span class='no-highlight'>Unit of Measure</span> </label> <label> <input class='priced-by-radiobutton' type='radio' name='qty_pkg' value='Qty' $pb2> <span class='no-highlight'>Quantity</span> </label> </div> </div> </div> <?php echo standardInputField('UoM Name/Pkg. Of:', 'pkg_of', $pkg_of, $errors); ?> <?php echo standardInputField('Price:', 'price', $price, $errors); ?> <?php echo standardInputField('Flyer Page #:', 'flyer_page', $flyer_page, $errors); ?> print_r($_POST); if ( !empty($_POST)) { // keep track of $_POST(ed) values by storing the entered values to memory variables $store_id = $_POST['store_id']; $item_id = $_POST['item_id']; $qty_pkg = $_POST['qty_pkg']; $pkg_of = $_POST['pkg_of']; ... ... $sql = "INSERT INTO shoplist (store_id,item_id,qty_pkg,pkg_of,price,flyer_page,limited_time_sale,flyer_date_start,nos_to_purchase,section_id,shopper1_buy_flag,shopper2_buy_flag,purchased_flag,purchase_later_flag,no_flag_set) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $q = $pdo->prepare($sql); $q->execute(array($store_id,$item_id,$qty_pkg,$pkg_of,$price,$flyer_page,$limited_time_sale,$flyerDateStart,$nos_to_purchase,$section_id,$initialize_flag_N,$initialize_flag_N,$initialize_flag_N,$initialize_flag_N,$initialize_flag_Y)); } else { echo "<br />There's something wrong somewhere!!!<br />"; print_r ($_POST); $qty_pkg = ''; $pkg_of = '';;Thanks. My array results keep displaying like this. I want it to just display the numbers in the quotations. any help? Code: [Select] array ( 0 => '4396', ) array ( 0 => '3934', ) array ( 0 => '5063', ) array ( 0 => '4394', ) array ( 0 => '3936', ) array ( 0 => '4393', ) array ( 0 => '4395', ) array ( 0 => '5064', ) array ( 0 => '5062', ) array ( 0 => '4224', ) array ( 0 => '3322', ) array ( 0 => '3321', ) array ( 0 => '3320', ) array ( 0 => '3725', ) Okay the problem is that it wont find the correct carrier. it dont even find it. i dont know whats wrong. Please take a look at the code. i dont know how to explain it better $carriers = array('verizon'=>'@vtext.com','tmobile'=>'@tomomail.com','sprint'=>'@messaging.sprintpcs.com','att'=>'@txt.att.net','virgin'=>'@vmobl.com','textnow'=>'@textnow.me','metro'=>'@mymetropcs.com','unknown'=>'@teleflip.com'); if (array_key_exists($carrier, $carriers)) { $correctCarrier = $carriers[$carrier]; $i = 0; While($i < $_POST['amount']) { $i++; $formatted_number = $to.$correctCarrier; $result = ("$i of Your Messages Has been sent to the number ". $_POST['to'] . ".<br>" . mail("$formatted_number", "$subject", "$message") . ""); } mysql_query("INSERT INTO `msgssent` (`number`, `numberofmsg`, `subject`, `message`) VALUES ('". $formatted_number ."', '". $i ."', '". $subject ."', '". $message ."')") Or die(mysql_error()); Echo $result; } Hey guys i have a table of pages set up with the possability of inserting pages inside pages. I am trying to make a delete button that would delete every child pages creating an array of page id's. page 1 L page 1.1 L page 1.2 L page 1.3 L page 1.4 page 2 my code looks like this so fare class delete_page { function page($cat_id, $x = ''){ $sql = mysql_query("SELECT * FROM pages WHERE parent='$cat_id' order by id asc"); while ($select = mysql_fetch_assoc($sql)) { $this->x[] = $select['id']; $this->x = $this->page($select['id'], $this->x); } return $this->x; } function get_page($cat_id){ return $this->page($cat_tid); } } $page = new delete_page; $get_array_page = $page->get_page(1); For some reason the above code sends me an array of all the pages in the database instead of returning only the child pages of the ID i inserted in the $get_array_page = $page->get_page(1) Code: [Select] Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) It should normaly return only page 1 L page 1.1 L page 1.2 L page 1.3 L page 1.4 with out page 2 like this Code: [Select] Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) What did i miss? I'm sure there must be a way to do whatI am after, as it seems like such an obvious thing to do, but I can't figure it out. 1. I have an array which contains a list of database's and their connections $slaveRes_array[0] = array('server' => 'localhost:3306', 'user' => $u, 'password' => $p, 'database' => 'MySQL01_5083', 'sendmail' => '0', 'repeat' => '0', 'dbID' => '1' ); and so on 10 times I then have a list of MySQL Queries: (at the moment there is only one, but there will be more later on). $query_array[] = array( 'query1' => "SHOW SLAVE STATUS"); The idea is that I take the first database from $slaveRes_array, connect to it, and run each query from the $query_array in turn against that database, and ultimately pass that resultset into an array that I can refer back to later on. Within $slaveRes_array I have a DB name (e.g. MySQL01_5083), I want this to be the first entry in my resultset array, so I can reference this. However, not all database's will return a result. So what I want to end up with is something like: => Array ( [name] => MySQL02_5083 ) ( [Slave_IO_State] => Waiting for master to send event)... (in this case the first server (MySQL01) didn't return a result, so the first item in the array is MySQL02. I have found lots of ways to achieve bits of this, but none that work together. I can get a list of database names that returned a result, but can't get the data to return to the array (or any array). I can get the data into an array, but not the database names. Surely this must be something straight forward that people do all the time, right? Hello all, I've been working on parsing through some XML data that is formatted as x-schema. It's been a challenge to say the least. I've looked at XMLReader and the like to see if I can parse through the data but with no luck. I found an approach that works but having trouble iterating over the nodes inside the nodes. I'll try to explain: Here's what I have so far. The code produces the following result set: Code: [Select] [4] => Array ( [FARM:NAME] => Array ( [FARM:NAME] => Kenyon Farm [FARM:FARM] => [FARM:TOTALAREA] => 999 [FARM:BUSINESSFIELDS] => [BUSINESSFIELD:FIELD] => [BUSINESSFIELD:LABEL] => K9 [BUSINESSFIELD:TOTALROTATIONS] => 1 [BUSINESSFIELD:TOTALAREA] => 998 [BUSINESSFIELD:FIELDOPTIONS] => [BUSINESSFIELD:FIELD_BOUNDARY] => [BUSINESSFIELD:DATAFILE] => FieldBoundary_2682 [BUSINESSFIELD:ACTIVITIES] => [CUST:FARMS] => ) ) Here's the code that produces that array: Code: [Select] $tuData=file_get_contents("xml/tim.xml"); $simple = $tuData; $p = xml_parser_create(); xml_parse_into_struct($p, $simple, $vals, $index); xml_parser_free($p); $getValue=""; $counter=0; print"<pre>"; print_r($vals); foreach($vals as $data) { if(isset($data['tag'])) { if($data['tag'] == 'FARM:NAME') { $key = $data['tag']; $counter++; } if(trim($key)!== '' && trim($data['tag']) !== '') { $arData[$counter][$key][$data['tag']] = $data['value']; } } } print"<pre>"; print_r($arData); Now to my problem. You'll notice that the array has a key called [BUSINESSFIELD:LABEL] ... in the attached xml file there can be more than one field for each farm. My current solution only gets the first field in the xml file (as the current example shows above) and moves to the next farm and creates a new array of data. I would like to get the other fields for each farm and "stuff" them in the same array. Array's are not my strong suite and would be grateful to anyone that could help me with this problem. Thanks a bunch! Hello All - I have the following array: Code: [Select] array 0 => array 'farmName' => string 'Hallinan' (length=8) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) 1 => array 'farmName' => string 'Holt' (length=4) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) 2 => array 'farmName' => string 'Holt' (length=4) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) 3 => array 'farmName' => string 'Holt' (length=4) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) 4 => array 'farmName' => string 'Holt' (length=4) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) 5 => array 'farmName' => string 'Holt' (length=4) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) 6 => array 'farmName' => string 'Home' (length=4) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) 7 => array 'farmName' => string 'Home' (length=4) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) 8 array 'farmName' => string 'Home' (length=4) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) The data comes from a flat file that has (as you can see) many of the same names like Home and Holt. Is there a way to extract the first Holt and Home from the array and put those values in a new array? So my new array would look something like: Code: [Select] array 0 => array 'farmName' => string 'Hallinan' (length=8) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) 1 => array 'farmName' => string 'Holt' (length=4) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) 2 => array 'farmName' => string 'Home' (length=4) 'farmInsNum' => string '' (length=0) 'farmFSA' => string '' (length=0) I look through php.net and really couldn't find a function that could handle what I was after. I'm sure I'd have to use a combination of each() and reset() or maybe not? Any help would be very welcome. Thanks! I want to store all the hours 0,1,2,3... in my $time array but it returns the last value only and I dont understand why... Code: [Select] <?php $time = array(); $hour = 0; for ( $i=0; $i<=7; $i++ ) { $time['hour'] = $hour; $hour++; } ?> Hey guys, I've got a problem with an array sum. I tried doign array_sum(), and a few other stuff but none worked. Here's my code: Code: [Select] $upkeepcheck = $db->query("SELECT i.itmid, i.upkeep, inv . * , u.userid, u.will, u.maxwill, u.upkeepowed, u.money, h.hPRICE, hWILL FROM items i LEFT JOIN inventory inv ON inv.inv_itemid = i.itmid LEFT JOIN users u ON inv.inv_userid = u.userid LEFT JOIN houses h ON h.hWILL = u.maxwill WHERE i.upkeep >0"); $q5 = $db->query("SELECT * FROM settings WHERE conf_name = 'upkeep'"); while($upkeep=mysql_fetch_array($upkeepcheck)) { while($upkeep1=mysql_fetch_array($q5)) { if($upkeep['money'] > $upkeep['upkeep']) { $db->query("UPDATE users SET money = money - {$upkeep['upkeep']} WHERE userid = {$upkeep['userid']}"); } else { $db->query("UPDATE users SET upkeepowed = upkeepowed + {$upkeep['upkeep']} WHERE userid = {$upkeep['userid']}"); } if($upkeep1['conf_value'] == 'Stackup') { if($upkeep['upkeepowed'] > $upkeep['hPRICE']) { $db->query("UPDATE users SET will=100,maxwill=100 WHERE userid = {$upkeep['userid']}"); $db->query("UPDATE users SET upkeepowed = 0 WHERE userid = {$upkeep['userid']}"); event_add($upkeep['userid'], "You haven't paid your upkeep, so your house has been taken away. Next time sell some weapons or earn some more money to pay your upkeep!", $c); } } else if($upkeep1['conf_value'] == 'RemoveItems') { $rem = $db->query("SELECT i.itmid, i.upkeep, inv.*, u.userid, u.upkeepowed FROM items i LEFT JOIN inventory inv ON inv.inv_itemid = i.itmid LEFT JOIN users u ON inv.inv_userid = u.userid WHERE userid = {$upkeep['userid']}"); while($remove = mysql_fetch_array($rem)) { if(isset($remove['upkeep'])) { var_dump($remove['upkeep']); $upkeep = $upkeep + $remove['upkeep']; } } } } } The part that is messed up is Code: [Select] $upkeep = $upkeep + $remove['upkeep'];var_dump($remove['upkeep']); produces: Quote null string '100' (length=3) which is correct, I have 4 null values and 1 value of 100. And the error I get is: Fatal error: Unsupported operand types in C:\wamp\www\pagetest.php Any ideas how to fix this? I want the $upkeep to be updated with $remove['upkeep'] if the value isn't null. Hello mates, i've been googling about my problem but i couldn't fix it. Code: ###################################### $web = file_get_contents($tmpUrl); $explodedWeb = explode("<b>Somecode:</b> ",$web); print $explodedWeb [1]; ###################################### I'm just printing it for testing purposes, and the $web var works fine(since tried printing the hole source). Error: "Notice: Undefined offset: 1 in ..." I tried to create an empty array in explodedWeb ("$explodedWeb[]") but didn't work either. Greets. Hello all, I think I have a simple question. I have several arrays that I need the output from but I need the output from each array to be together. I know WHAT?! I'll try to explain: I have a dynamic jQuery form that fills in a table with data. Each "field" or <td> has separate information in each. The way I output the data is in an input box so that I can capture the value of each. The name attribute is the array for each input. So for example the output for each would look like this: Code: [Select] <tr> <td> <input type="text" name="fullName[]" value="input_from_user"/> </td> <td> <input type="text" name="Address[]" value="input_from_user"/> </td> </tr> If you can visualizes this we could have several rows of data from each array (fullName[] and Address[]). How would I extract the data in such a way that I can clump them into their appropriate rows? I know how to extract them one by one using foreach loop on each array but that won't do what I want. I would like the output to be like this: John Doe - 22 S Main Street Jim Smith - 111 N Main Street and so on... This is what I have so far but I'm sure this isn't how to accomplish what I'm after. $name = $_POST['fullName']; $address = $_POST['Address']; $outputArry = array( "FullName" => $name, "Address" => $address ); foreach ( $outputArry as $output ) { foreach ( $output as $row ) { $rowFullName = $row['FullName']; $rowAddress = $row['Address']; $rowOutput .= 'Name: ' . $rowFullName . ' Address: ' . $rowAddress . '<br />'; } } echo $rowOutput; Thanks for any help on this issue. Damian For some reason this array will only return 'white'. Is there a problem with the code?
<?php $test = array('blue','green','white'); foreach($test as $val) ?> <?php echo "$val"; ?> I am extracting an array from the database in sorted form with respect to it's parent_id. Now I have to make a sub tree of this array in such a way that related nodes would be inserted in 'pages' field. cleths->upper->shirts I came accross a problem where im not sure how to add the word "and" inbetween my variables. I'm only displaying one $field below but i have 6 of them. If I add and as the seperator in the implode it will repeat it and and. Also it will put it at the end Code: [Select] <?php $field1 = "Farms to " . $_POST['farms_population']; $a = array("$field1", "$field2", "$field3", "$field4", "$field5", "$field6"); $_SESSION['changed'] = "You have changed " . implode(" ",$a); echo $_SESSION['changed']; ?> wanting it to echo something like You have changed Farms to 30 and Larva Pools to 10 and Homes to 10 |