ShawnCplus 456 Code Monkey Team Colleague

Is there some absolutely halting reason that the joomla stuff can't be hosted on the same server? It's not like its that hard to port a database and rsync code

ShawnCplus 456 Code Monkey Team Colleague

If you want perfect html and perfect php using my method then I would use something like the following:

<?php
//pre define tab indents
$t1=' ';
$t2='  ';
$t3='   ';
$t4='    ';
$t5='     ';
$t6='      ';
$t7='       ';
$t8='        ';
$t9='         ';
$t10='          ';
$t11='           ';
$t12='            ';
$t13='             ';
$t14='              ';
$t15='               ';
$t16='                ';
$nl="\n"; //new line variable

I don't even know how to respond to that.... just... wow.

ShawnCplus 456 Code Monkey Team Colleague

I agree but in my belief, you should only ever have one php opening tag and one php closing tag in a php file. Then all html output should be done through php functions because otherwise it gets too confusing. And it's easier to manage that way.

Wow, we definitely have complete opposite thoughts on it. I've dealt with some absolutely horrible spaghetti code that was created by having PHP echo all of the HTML. Not only do very few editors highlight HTML when they're inside of strings but if you're just using strings and heredoc and you still want to maintain good indentation and readability of the HTML then you might as well just exit PHP and write it directly.

<?php
  echo "<h1>Some Page Title</h1>\n";
  $some_variable = "Hello World!";
  while ($blahity_blah) {
    // some other logic we don't care about
  }
  // do some more random stuff
  echo '<h3>' . $some_variable . "</h3>\n";
  for (/* more random stuff */) {
    // blah
  }
  echo '<table>
  <tr><td>Hello!</td></tr>
  <tr>
    <td>World!</td>
    <td>Goodbye</td>
    <td>World</td>
  </tr>
</table>';
?>

Vs

<h1>Some Page Title</h1>
<?php
  $some_variable = "Hello World!";
  while ($blahity_blah) {
    // some other logic we don't care about
  }
  // do some more random stuff
?>
<h3><?php echo $some_variable ?></h3>

<?php
  for (/* more random stuff */) {
    // blah
  }
?>
<table>
  <tr><td>Hello!</td></tr>
  <tr>
    <td>World!</td>
    <td>Goodbye</td>
    <td>World</td>
  </tr>
</table>

The whole point of it is to separate display logic (HTML) from control logic (PHP). In my opinion you should almost never ie., only …

ShawnCplus 456 Code Monkey Team Colleague

Don't try to mix creating your own json strings

$objJSON = array('sample' => null);
// whatever
$objJSON['sample'] = $arr;
$objJSON = json_encode($objJSON);
echo '<script type="text/javascript">var myJSON = ' . $objJSON . ';</script>
ShawnCplus 456 Code Monkey Team Colleague

Each to his own I suppose, but I reckon anyone who could understand while ($i++ < 3): should be able to understand the idea of a brace.
Still, I ain't arguing the point, just not convinced.

*nod* Maybe I've just met a lot of dumb designers. I think the end point we can get from this is to just use PHP instead of bloated, even uglier templating engine :)

ShawnCplus 456 Code Monkey Team Colleague

Sorry to be picky, but this looks a lot more complicated than braces.

More verbose, yes. More complicated, no. If you go to a designer who has never used PHP and has never needed to balance braces and you ask them what a brace is or how to align braces they'll look at you dumbfounded. If you ask them what while/endwhile means if they have two braincells in their head they'll say endwhile ends a while.

To use the example from above

Short Tags

<?php $i = 0 ?>
<?php while ($i++ < 3): ?>
    <?php while($row=mysql_fetch_array($result)): ?>
      <td><?php echo $row['firstname'] ?></td>
      <td><?php echo $row['lastname']?></td>
    <?php endwhile ?>
<?php endwhile ?>

Braces

<?php $i = 0;
while ($++ < 3) {
    while ($row = mysql_fetch_array($result)) {
?>
    <td><?php echo $row['firstname'] ?></td>
    <td><?php echo $row['lastname']?></td>
<?php
    }
}
?>
ShawnCplus 456 Code Monkey Team Colleague

Sure that sometimes works ShawnCplus however you cannot have a loop inside a loop using that method. An example of invalid code is as follows:

<?php $i=0
while ($i<3):
    $i++;
    while($row=mysql_fetch_array($result)): ?>
      <td><?php echo $row['firstname'] ?></td>
      <td><?php echo $row['lastname']?></td>
    <?php endwhile
endwhile ?>

The above code will never work because you cannot have a while loop inside a while loop when not using brackets. So best practise is to use the brackets.

You most certainly can use nested whiles with that syntax

This worked perfectly fine for me

<?php $i = $k = 0 ?>
<?php while ($i++ < 10): ?>
  Hello
  <?php while ($k++ < 3): ?>
    World
  <?php endwhile; $k = 0; ?>
<?php endwhile ?>
ShawnCplus 456 Code Monkey Team Colleague

PHP has built-in constructs that make it look like a templating language so you don't need the bloat of another templating class. I also prefer this method as people dealing with the files don't have to know what braces mean but its obvious what endwhile means.

<?php while($row=mysql_fetch_array($result)): ?>
  <td><?php echo $row['firstname'] ?></td>
  <td><?php echo $row['lastname']?></td>
<?php endwhile ?>
ShawnCplus 456 Code Monkey Team Colleague

Looks like you have carriage returns in the data do

fwrite($fp, str_replace("\n", '', (date('d M - H:i') . '||' . $route_dept . '||' . $route_dest . '||' . $route_dist . '||' . $route_demd) . "\n");
ShawnCplus 456 Code Monkey Team Colleague

Resource #1 search the forums before posting,
Resource #2, use google
Resource #3, php.net

*quietly ponders how many people will get the hidden PHP joke*

ShawnCplus 456 Code Monkey Team Colleague
'"string with"'

is invalid, '' are used for chars, "" are for strings.

"\"string with\""

is that string

ShawnCplus 456 Code Monkey Team Colleague
somestring = "this is a \"string with \" quotes";
ShawnCplus 456 Code Monkey Team Colleague

mysql and php with xampp is exactly the same as mysql and php on their own. All XAMPP does is put it in an easy-to-install package

ShawnCplus 456 Code Monkey Team Colleague

The problem is that get_browser returns an array, not an object. use $b['parent'] , not $b->parent

ShawnCplus 456 Code Monkey Team Colleague

http://gtk.php.net/ There ya go.

ShawnCplus 456 Code Monkey Team Colleague

Did you try, maybe, http://php.net/xml?

ShawnCplus 456 Code Monkey Team Colleague

That is the "actual php coding" What's wrong with it exactly? Also, see the include s those are other files that you can open and look in

ShawnCplus 456 Code Monkey Team Colleague

well show us the current code so we can help you out, not a lot we can do right now.

ShawnCplus 456 Code Monkey Team Colleague

I'm new to this technology. I'd be glad if somebody help me in starting this and guiding me where to start? and how to start? to learn this new technology.

I already answered this in the other forum where you posted.

ShawnCplus 456 Code Monkey Team Colleague

I'm new to this technology. I'd be glad if somebody help me in starting this and guiding me where to start? and how to start? to learn this new technology.

A) Wrong forum, B) Google is your friend, along with php.net and pretty much any of the first million results from searching PHP in any search engine

ShawnCplus 456 Code Monkey Team Colleague

i want source code for chat in php and mysql

Cool, how's that working out for you?

Ezzaral commented: My thought exactly :) +24
ShawnCplus 456 Code Monkey Team Colleague

Well you could turn magic quotes off http://php.net/magicquotes or you can use the stripslashes function

ShawnCplus 456 Code Monkey Team Colleague

The place to start debugging is by echoing the variable to see if it is what you think it is. You may have magicquotes turned on and O'Reilly is actually O\'Reilly

ShawnCplus 456 Code Monkey Team Colleague

Strange, I tested it and it works fine for me. O'Reilly matches, Smith matches, Smith-Jacobs matches. The only thing that doesn't match is stuff like @#$%@#

ShawnCplus 456 Code Monkey Team Colleague

%3C and the link are url encoded, use url_decode to decode them.

ShawnCplus 456 Code Monkey Team Colleague

I'm a big fan of Doctrine, Wage (the lead developer) is a smart guy but Doctrine is kind of heavy-weight. As for copy on write, that's true for every variable in PHP if I remember correctly.

ShawnCplus 456 Code Monkey Team Colleague

The objects are actually stored in some persistent storage, at the moment I'm using a custom build Object cache but it also interfaces with memcached, APC, etc.

The problem is that the storage could be on an external domain, I'd like to minimize the data sent between the storage and actual PHP script.

Say the object is 1Mb, it would be ok in the PHP script, but not sent back and forth between the storage and php scripts requesting it.

I'm actually starting to think I should take different approaches for differnt types of objects. Maybe different means for large Array, or even constricting the types of objects that can be stored..

If you want smaller transfer sizes then now you're staring at a performance vs. size issue. If you want smaller transfers at the cost of performance then the obvious solution is compressed serialization (using either PHP's serialize or another method then using gzip/etc. to compress the data). That method would, just as obviously, be a big hit to performance.

The "perfect" solution would probably be a middle ground but it really just ends up being an engineer decision between can you afford to throw hardware at it or you have a quick connection :)

ShawnCplus 456 Code Monkey Team Colleague

A) we can tell you're new, you didn't read that you should use code tags.
B) You're missing all of your closing tags.

}
    }
  }
}

should go right before the end tag

ShawnCplus 456 Code Monkey Team Colleague

Your example should work the way you want it. There is no dimensioning of arrays in PHP, space is allocated as necessary.

ShawnCplus 456 Code Monkey Team Colleague

Yeah, don't use both mootools and jquery. If you want a lightbox use Thickbox which uses jQuery, I'm not sure what mootabs is so I can't suggest a replacement for that.

ShawnCplus 456 Code Monkey Team Colleague

Although I'm not sure how you want the surrounding data split, the data mentioned in post #1 would be matched like the following:

<?
$string = '"yZoomedDataMax":82060000,"time":"1980","sizeOption":"_UNISIZE","xLambda":1,"xZoomedDataMin":20273,"yZoomedDataMin":1353355,"stateVersion":3,"xAxisOption":"3","playDuration":15,"iconKeySettings":[{"trailStart":"1980","key":{"dim0":"Netherlands"}},{"trailStart":"1980","key":{"dim0":"Switzerland"}},{"trailStart":"1980","key":{"dim0":"Austria"}}],"yAxisOption":"4","yZoomedIn":false,"xZoomedIn":false,"orderedByY":false,"colorOption":"2"}';
//echo $string;
preg_match_all('/\{"([^"]+)":"([^"]+)","([^"]+)":\{"([^"]+)":"([^"]+)"\}\}/',$string,$array);
echo '<xmp>';
print_r($array);
echo '</xmp>';
?>

This is marked as solved but it wasn't solved correctly. This just just JSON data, use json_decode

ShawnCplus 456 Code Monkey Team Colleague

The easiest way is method 2. Frankly, there would be very little overhead in comparison to the first method, they're both function calls except one (the magic method... method) doesn't have to do a check to see if __get/set exist since it knows you're calling a function.

Now, given that you're not using __get/set you would have to sort of emulate or wrap all of the functions you want to apply to the object like array_sort or array_walk, etc. to check for modifications

ShawnCplus 456 Code Monkey Team Colleague

You use . to concatenate so echo ucwords($_SESSION['fname'] . ' ' . $_SESSION['lname']);

ShawnCplus 456 Code Monkey Team Colleague

You can't, the form fields must have separate names. If you have a bunch of Select1=blah in the URL only the last one will actually assign the value.

ShawnCplus 456 Code Monkey Team Colleague

well there's your answer:

document.getElementById("divCheckBoxList");

Isn't returning anything, it can't find that element. My first tip is to use Firefox and Firebug so you can actually see the error since Internet Explorer has pretty much every JS error as Object Expected because everything in JS is an object

ShawnCplus 456 Code Monkey Team Colleague

divRef probably doesn't exist, show the whole code not just one line.

ShawnCplus 456 Code Monkey Team Colleague

Can someone please conver the following code into a sequence diagram for me? the 4 instances and classes with the life lines are: theUI:UserInterface, theCashPoint:CashPoint, theActiveAccount:BankAccount and transactions:TransactionList

void CashPoint::m4_produceStatementForBankAccount() const {
    string statement( p_theActiveAccount_->prepareFormattedStatement());
    theUI_.showStatementOnScreen( statement);
}


string BankAccount::prepareFormattedStatement() const {
    ostringstream os;
    //account details
    os << prepareFormattedAccountDetails();
    //list of transactions (or message if empty)
    if ( ! transactions_.isEmpty())
        os << "\n\nLIST OF TRANSACTIONS \n"   << transactions_.toFormattedString(); //one per line
    else
        os << "\n\nNO TRANSACTIONS IN BANK ACCOUNT!";
    return ( os.str());
} 

end quote.

You might want to see your other post where you copy/paste homework questions for my answer.

ShawnCplus 456 Code Monkey Team Colleague

Please can you help me with the following question?

An iterative version of the C++ function TransactionList::getTransactionsForDate is given below. It can be applied to any list of transactions and returns the list of all the transactions for the given date. It only works when the date given is valid.
Write an equivalent recursive version of that function so that it can be used in the same way and produces the same result.

I added these tags for you

TransactionList TransactionList::getTransactionsForDate( const Date& date) const {
	assert ( date.isValid()); 
	TransactionList copyTrl( *this);
	TransactionList tempTrl;
	while ( ! copyTrl.isEmpty() )
	{
		if ( copyTrl.first().getDate() == date)
			tempTrl.addAtEnd( first());
		copyTrl.deleteFirst();
	}
	return tempTrl;

}

I'll help you first by saying this isn't your first post, it's your 11th, you should know how to use code tags by now. You should also know that we don't give help to those who don't show effort.

Salem commented: It's getting tiresome isn't it? +36
ShawnCplus 456 Code Monkey Team Colleague

You don't need the button to add the timestamp, you can do that in PHP. All you need the buttons to do is the in or out.

ShawnCplus 456 Code Monkey Team Colleague

You described function overloading, not overriding. Overriding is replacing the implementation of a method with a specialized implementation in a derived class.

I hate when I brain changes words in sentences without telling me, in my defense I use the word method for class methods only and functions for globally namespaced functions

ShawnCplus 456 Code Monkey Team Colleague

The problem is that, in my experience in input forms, you have to designate which PHP component it will use in the "form action" field, but I'm using two different PHP actions.

Maybe there's a way to use the clock-in and clock-out buttons as a sort of "toggle" inside the php form rather than completely separate forms.

If by action you mean file, don't do that. Really for something this simple this should only be one file in total (ie., the form posts to the page it exists on)

ShawnCplus 456 Code Monkey Team Colleague

realy i did not understand that what function over riding means
can any body help me for that please

A) Use google or Daniweb Search
B) Say you have a function that you want to work on both strings and chars for example I have a function to convert a decimal number to a binary string (Hi -> 0100100001101001)

string decbin(char a)
{
  string dest;
  int rem = a;
  for (int i = 7; i >= 0; i--) {
    dest += (rem / (1 << i)) ? '1' : '0';
    rem %= (1 << i);
  }
  return dest;
}

string decbin(string* inp)
{
  string result = "";
  for (unsigned int i = 0; i < inp->length(); i++) {
    result += decbin((*inp)[i]);
  }
  return result;
}

So I have two functions, both which have the same name, but based on the TYPE of the parameter passed do two separate things, ie.,

char mychar = 'a';
string mystring = "Hello World";
string mycharbin = decbin(mychar); // calls decbin(char)
string mystringbin = decbin(mystring); // calls decbin(string)
ShawnCplus 456 Code Monkey Team Colleague

They don't have to be submit inputs, they can be button tags which set a field to say clockin or clockout and then submit the form though you could do exactly the same thing with submit inputs

ShawnCplus 456 Code Monkey Team Colleague

The same exact way you did with Person except replace Person with Patient

class Patient : public Person {};
class StudentPatient : public Patient {};

http://www.cprogramming.com/tutorial/lesson20.html

ShawnCplus 456 Code Monkey Team Colleague

http://php.net/SimpleXML, You might want to take a look at the xpath stuff.

ShawnCplus 456 Code Monkey Team Colleague

Can anyone help me out on this?

Google can, wikipedia can, really any method of self-improvement beyond asking for help before trying to help yourself.

ShawnCplus 456 Code Monkey Team Colleague

http://php.net/print_r]print_r[/url][/icode] will print an array and its contents like you see in

Array (
 [0] => this
 [1] => sentence
)

http://php.net/echo]echo[/url][/icode] simply echoes a string. It says "Array" because when an array is converted to a string that is the output.

ShawnCplus 456 Code Monkey Team Colleague

http://php.net/is_float The manual is your friend

ShawnCplus 456 Code Monkey Team Colleague

well i have indeed chosen the aliendb (database) . But the whole point is , by doing so its inserting the values by default in the first table (alien).
But i want to insert the data in the second table of the same DB , which is store. So how do i select the other table inside the DB ?

You aren't locked into tables, only the database. So once you select the database you can use SELECT/INSERT/UPDATE/etc. on any table in that database. You might want to read up on a few MySQL tutorials (take a look at w3schools) to see how to work on different tables.

ShawnCplus 456 Code Monkey Team Colleague
window.onunload = removeLoggedIn();

Should Be

window.onunload = function () {
  removeLoggedIn();
};
// OR
window.onunload = removeLoggedIn;

You don't want to assign the result of removeLoggedIn to the onunload, you just want to assign the function to it.