darkagn 315 Veteran Poster Featured Poster

I think if you remove the line

traverseInOrder.successor.predecessor = newNode

your algorithm will be correct. Remember, node.successor.predecessor should always equal node unless node is the last node in the list. Same with node.predecessor.successor, unless node is the first in the list.

darkagn 315 Veteran Poster Featured Poster

Hi Ballen92 and welcome to DaniWeb :)

What's the error message you get? If I had to guess on the information you've given us, I would say that the method addKeyListener is not defined for your class. What class does Robot extend?

darkagn 315 Veteran Poster Featured Poster

Sorry hedwards09, we can only give homework help to those that make an attempt first. Can you post what you have so far with the specific problems you are having? If you haven't started coding yet, what ideas do you have so far? We may be able to guide you if you show that you have made a start.

darkagn 315 Veteran Poster Featured Poster

Sorry for the late reply, I was at work and got distracted doing, well work :P Well your code looks ok to me, could it be that the problem lies in user_list.php with retrieving the $_GET["message"] variable? The only other thing I can think of is that the user level is ok for the access you are trying to attain?

If you don't see error messages in your browser then you aren't actually generating an error, it's just not doing what you want :P

darkagn 315 Veteran Poster Featured Poster

Has your session started correctly before the call to your function? Check by echo'ing $_SESSION["Last_Page"] and make sure it's what you expect.

What error message do you generate?

darkagn 315 Veteran Poster Featured Poster

The line:

Criminal criminal = new Criminal(leftInput.name());

is trying to access the private variable leftInput which doesn't belong to your class. You only have access to the parameter e in this method.

darkagn 315 Veteran Poster Featured Poster

Hi bhoop and welcome to DaniWeb :)

There are tools out there that allow you to create an exe from a java application. However this defeats one of the main advantages of java, portability. You would need a pretty good reason to go down that path, I believe...

darkagn 315 Veteran Poster Featured Poster

Try adding the following line to your script, anywhere after the line $dir = $documentroot . '/' . $username; but not inside the function:

rmdir_r($dir);

Basically, the code inside the function doesn't execute until the function is called.

aeinstein commented: nice catch and good solve Darkagn +8
darkagn 315 Veteran Poster Featured Poster

You need to do this in two separate SQL queries. First, use a select statement to retrieve the location ID given the posted area. Then use this result as the location number when inserting to the device table.

darkagn 315 Veteran Poster Featured Poster

Hi erlene and welcome to DaniWeb :)

You have posted in the Game Development forum which is a forum for discussing game programming. I think you will have a better response from one of the tech forums on this site.

I will say though that there are a number of things that could be happening. I think most likely there is a problem with your video card (just a guess). Try running the game on lower quality graphics and see if this helps you.

Good luck :)

darkagn 315 Veteran Poster Featured Poster

Your error message is telling you what has gone wrong with this line:

if (hours == 16 && minutes == 23)

Here you are trying to compare your variable hours which is a NumberDisplay object with the number 16, which is an int. That's like saying "If this apple equals this orange" - how do you compare an apple to an orange? What you need to do is compare the hours to the NumberDisplay object with the value 16 (if that's what you really want to do?) Same goes for minutes variable...

darkagn 315 Veteran Poster Featured Poster

Hi intet,

We only give help to those who show some effort. What have you tried so far?

darkagn 315 Veteran Poster Featured Poster

Hi easyb and welcome to DaniWeb :)

You don't need to use Math.pow at all. Math.pow is used to find the power of a number. I wish that banks would pay interest exponentially but unfortunately... ;)

I suggest you revise your notes on iteration and for-loops. I think what you want would look something like this:

for(n=1; n<=10; n++) {
  P = P * (1+r); // a better solution would be to have r = 1.05
  System.out.println("The amount at the end of the year " + n + " is:" + P);
}
darkagn 315 Veteran Poster Featured Poster

Hi Vikk and welcome to DaniWeb :)

Have you made an attempt at this query yet? If you post what you have done we might be able to see what you are trying to accomplish and give some pointers.

darkagn 315 Veteran Poster Featured Poster

I studied scheme at university for a semester and I don't remember much besides lots and lots of brackets. Most of the problems I had with it all boiled down to the fact that I had unbalanced brackets in my statements. Other than that it was relatively straight forward to work out what was going on from the lecture notes and other resources. What specifically are you having trouble understanding?

darkagn 315 Veteran Poster Featured Poster

Hi raz0r and welcome to DanoWeb :)

Not sure exactly what you are trying to do, but the rand function will give you a random number. You can read more about the rand function here.

By microtime, do you mean time to the microsecond? If so, this can be achieved using the microtime function. Here is a link to its documentation.

Let us know if I am off base with what you were after. Good luck!

darkagn 315 Veteran Poster Featured Poster

This section is commented out:

<?
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="brijpuja1"; // Mysql password
$db_name="newsumo"; // Database name
$tbl_name="users"; // Table name
 
$username=$_POST['username'];
$oldpass=$_POST['oldpass'];
$newpass=$_POST['newpass'];
$conpass=$_POST['confirmpass'];

$encry_oldpass=md5($oldpass); //encrypting old password
echo "$encry_oldpass";

But I think you need it to connect to the database and retrieve the details from the form. You should also validate all $_POST variables.

Also, you set $username to "root", then overwrite it with $_POST["username"]. You need to make sure they are different variables.

darkagn 315 Veteran Poster Featured Poster

Hi catcoffee and welcome to DaniWeb :)

1) Can be achieved with a <input type='file'> in a PHP/HTML form. PHP then uses an array, $_POST, to retrieve all posted data and the $_FILE array to access uploaded files.
2) By validation do you mean making sure that the inputted data is acceptable? If so, PHP provides regex functions that can be performed on your $_POST array as well as other ways of validating your form data.
3) and 4) I don't follow what you need here?

darkagn 315 Veteran Poster Featured Poster

Try this:

$query2 = "SELECT tblclasslist.studentNo FROM acumenchain.tblclasslist JOIN acumenchain.tblregistration ON tblclasslist.studentNo = tblregistration.studentNo JOIN acumenchain.tbllogin ON tblclasslist.studentNo = tbllogin.studentNo AND tbllogin.studentNo = tblregistration.studentNo";

Does this give the desired result?

darkagn 315 Veteran Poster Featured Poster

Not sure what DaniWeb's policy is, but for other forum-type sites that I have contributed to we kept all PM's, emails, forum posts in database tables. If the owner of the message deleted it (by pressing a button for example) then we archived the message to another database table that was not accessible to the general public. This way we had a record of abusive posts, bullying etc even if the sender tried to delete it.

From a legal standpoint there are only certain things that are illegal to store. Off the top of my head I know that signatures (that is hand-written credit card authorisations) have legal implications for example. But things like emails, forum posts, blogs etc should be ok to store indefinately.

darkagn 315 Veteran Poster Featured Poster

From the PHP Documentation:

Note: Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as Runtime Configuration in your PHP configuration and leave the server field blank.

Try changing localhost to 127.0.0.1 and see if this fixes your problem. If not, try echo'ing mysql_error() instead of "fail" as this will give you more details as to why your connect call is failing.

darkagn 315 Veteran Poster Featured Poster

Ok, so are you saying that your font doesn't work when you try to display text with PHP via an echo or print? How are you setting the font without using HTML or CSS?

darkagn 315 Veteran Poster Featured Poster
String number = Float.toString(number);

I think what you are trying to do is convert the number n to a string yes?

What I would do is this:

String number = new Float(n).toString();

Here I create a Float object from my float primitive, then convert it to a String. You have tried to call the toString method statically and then pass the variable number instead of n.

darkagn 315 Veteran Poster Featured Poster

Your line:

while (i<=k)

is placed before k is properly initialised. I think you need a line inserted to receive the input that you are prompting for. That is similar to your line that reads:

x=input.nextDouble();

but for k instead of x (I'll let you figure that out). Not sure if this is your only error, but it will at least allow your loop to run.

Also, to help us to help you, please describe the error you are receiving, don't just say there are lots of errors as that doesn't really tell us much.

darkagn 315 Veteran Poster Featured Poster

Hi ankiwalia and welcome to Daniweb :)

Your SQL syntax is incorrect. Instead of this:

String query="select username and password from Registeredusers";

Try this:

String query="select username, password from Registeredusers";
darkagn 315 Veteran Poster Featured Poster

Lots of noobs have trouble connecting to a MySQL database and running queries, displaying results etc.

Another good tutorial might describe the differences between the popular browsers such as IE, FF, Safari, Chrome etc. All good web developers need to know what to expect, but too many only focus on their favourite browser.

darkagn 315 Veteran Poster Featured Poster

What does EOT mean?

darkagn 315 Veteran Poster Featured Poster

I remember when I was really young on the Apple II playing games like Taipan (which was a pirates / smuggling game) and Chivalry (where you were a knight who wandered the land and competed in jousting tournaments and the like). It was also around this time that I was playing the old Nintendo hand-helds with games like Donkey Kong, Mario Bros, etc. I also had this portable pacman game that I spent way too long playing!

I also remember when the first Warcraft game came out and thinking how awesome it was. Well I loaded it up the other day and certainly games have come a LONG way since!

darkagn 315 Veteran Poster Featured Poster

Somewhere in your code you are passing a null value when you can't. If I had to guess I would say your problem occurs somewhere near these lines of code:

URL url = this.getClass().getResource("logo.jpg");
Image img = Toolkit.getDefaultToolkit().getImage(url);
darkagn 315 Veteran Poster Featured Poster

1/2 is 0 remainder 1 because you have 0 whole divisions into 2. You are correct in saying that it is 0.5, but when doing a conversion between bases we deal only in whole numbers.

darkagn 315 Veteran Poster Featured Poster

Hi surf and welcome to DaniWeb :)

echo '<option value=\"$key\">$value </option>\n';

This line is your problem. Swap all ' with " and vice versa. The problem is that $value is not evaluated inside single quotes. Your code should look like this:

echo "<option value='$key'>$value </option>\n";

Note that $key will be evaluated still because the single quotes are nested inside double quotes.

darkagn 315 Veteran Poster Featured Poster

Does a window open and the problem is that it is just blank? Or does no window open at all? Truly, I can't see what's wrong with your code, the syntax looks correct, maybe try echoing $row beforehand to make sure that you are using the correct value?

darkagn 315 Veteran Poster Featured Poster

Yes that's right. This might help:

$results = mysql_query("SELECT a.column1, a.column2, a.column3 FROM table1 as a");
while(($nextRow = mysql_fetch_assoc($results)) !== false)
{
      $data[]["col1"] = $nextRow["column1"];
      $data[]["col2"] = $nextRow["column2"];
      $data[]["col3"] = $nextRow["column3"];
}
echo "<br /><table border='1'><tr><th>column1</th><th>column2</th><th>column3</th></tr>";
foreach($data as $row)
{
    echo "<tr><td>{$row["col1"]}</td><td>{$row["col2"]}</td><td>{$row["col3"]}</td></tr>";
}
echo "</table><br />";
darkagn 315 Veteran Poster Featured Poster

For example, with CSV file format, each row of data is a row in the csv file and each column is separated by a comma. So what you need to do is this:

// let's say the report.php file has a table of data called $table
// and we want to export that data to the file export.csv
// first we open the file that we want to write to
$export_handle = fopen("export.csv", "w"); // note the "w" format here
// make sure that we opened it
if(! $export_handle)
{
   echo "Error opening file.";
   die;
}
// we need to get each row in the table and write it to the file, so...
foreach($table as $row)
{
   // in each row there are several columns that we need to output
   // note you could also use the implode function here, but for illustration purposes...
   foreach($row as $column)
   {
      $result = fwrite($export_handle, $column . ",");
      // check the write succeeded - $result = number of bytes written
      if($result === false)
      {
         echo "Error in column write.";
         die;
      }
       // each row needs to have a carriage return appended
       $endLine = fwrite($export_handle, "\r\n");
       // check write was ok
       if($endLine === false)
       {
            echo "Error in row write.";
            die;
       }
   }
}
// here we need to cleanup after ourself by closing the file
fclose($export_handle);

Hope this illustration helps. Other formats will be different in what gets written, but the basic algorithm is the same for any export.

darkagn 315 Veteran Poster Featured Poster

Ok, that's what I meant from providing an export facility. From your original description I thought maybe you meant you want to convert your php source code to html or something.

So, your function should do the following:
- get table data
- open a destination file using fopen('w')
- write to the file using fwrite
- close the file using fclose

Hope this gives you a start. Have a try and repost with your code if you get stuck.

darkagn 315 Veteran Poster Featured Poster

PHP dom parser looks to be the right solution but i have had trouble
getting it to work.

Have you tried the DOMDocument::getElementById() function? Can you post your coding attempt with the DOM parser please?

darkagn 315 Veteran Poster Featured Poster

$results is a resource that can be used to grab an array using any of the mysql_fetch functions:

while(($nextRow = mysql_fetch_assoc($results)) !== false)
{
   $column1 = $nextRow["column1"];
   // etc
}

The loop will stop when there are no more records to be fetched.

darkagn 315 Veteran Poster Featured Poster

Hi lcyew and welcome to DaniWeb :)

Do you mean that you want to provide an export facility, or that you need to export your source code to those formats?

To provide an export facility you need to:

- read the contents of the file to be exported using file_get_contents and change format if necessary for the new file format (might not need to parse)
- open destination file using fopen('w') -> the 'w' means write and create new rather than append
- use the returned resource to write the contents of the file to be exported using fwrite

For more info on these functions (and some good examples of file manipulation) check the documentation at www.php.net.

darkagn 315 Veteran Poster Featured Poster

Hi Davros and welcome to DaniWeb :)

So are you trying to change the code that embeds the editor on the fly? If so, according to what criteria? I'm a little confused as to what you want to achieve.

darkagn 315 Veteran Poster Featured Poster

Try it like this perhaps?

echo "<input type=\"image\" src=\"ViewHotel.PNG\" name=\"image\" width=\"90\" height=\"24\" onClick=\"window.open('viewhotel.php?id={$row['id']}, 'mywindow', 'width=400, height=200')'\"/>";

I think the problem is that you are already in php and echoing the string, so you can't nest a <?php ?> tag inside the html. There is also a problem with the quote marks, but I think the above code should take care of that.

EDIT: Also, in order to evaluate an array element inside double quotes, it needs to be surrounded by braces, thus the {$row}.

darkagn 315 Veteran Poster Featured Poster

Hi duckman_ca,

I'm fairly new to C# so I don't know xml.InnerText, but XML parsing in PHP is quite simple thanks to several libraries we have available. Take a look at SimpleXML or the standard DOM library as a start, but there are others. For a full list and documentation, see www.php.net/manual/en/refs.xml.php

Hope this gives you some starting reading, feel free to post back with any questions you may have :)

darkagn 315 Veteran Poster Featured Poster

Hmm, I can't see what's wrong there, can you post the whole line of code please? Also, what is the error message you are getting when you run the code?

darkagn 315 Veteran Poster Featured Poster

Try this:

<?php
// php code here
?>
<!-- HTML code here -->
<input type='button' name='myButton' id='myButton' onClick="window.open('viewhotel.php?id=\'<?php echo $row['id']; ?>\',\'mywindow\',\'width=400,height=200\')'" />

Is that what you meant?

darkagn 315 Veteran Poster Featured Poster

Personally I find it difficult to critique UML when I am not sure exactly what you are trying to achieve, but I'll give it a go. It looks good except for a couple of things that I noticed.

First of all, you have a User having a Family, I think it could possibly be better to have the family having a list of users and functions such as isFamilyMember($user) . I think this would be a cleaner solution.

The other thing I noticed is that Users, Families and Companies all have a Bank object, and Users also have a Family and a list of Companies. This to me seems a bit too much, perhaps you need to think about what you are trying to achieve with your Bank object.

Other than that, the UML looks like a good start for how these classes might interact, but you need to keep in mind that PHP is not an object-oriented language although it does feature some support for classes.

darkagn 315 Veteran Poster Featured Poster

Using double quotes in PHP has many advantages, not the least of which is that all variables will be evaluated inside them. Consider the following code:

for($i=0; $i<10; $i++)
   echo "$i ";

This will output:
0 1 2 3 4 5 6 7 8 9
The following code:

for($i=0; $i<10; $i++)
   echo '$i '; // notice the single quotes

outputs the following:
$i $i $i $i $i $i $i $i $i $i
There are other advantages to using double quotes in php, including being able to use escape characters such as \n for a new line in plain text.

EDIT: Now in your specific example, The variables are inside double quotes and single quotes, because the single quotes are needed in the SQL statement but we need to evaluate the value of the variable.

darkagn 315 Veteran Poster Featured Poster

hi
iam tried to send mail
but see how it appear
iam use
mail function
when i make 2 line
the message appear
line one \n line 2

You need to set a new line as <br /> in an HTML email or \r\n in a plain text email.

and how i can make it go to the inbox and not spam

This is to do with the recipient's spam filter settings. To try to minimise your spam score you can, only send to one recipient at a time in the TO field, or send to as many as you like in the BCC field with noone in the TO field, make sure you specify a reply email address, specify your name in the From field in the format "darkagn <darkagn@myisp.com.au>", etc

and its appear some time strange
how can i make it english with the encode

Not sure what you are asking here, please explain a bit more what you are after, perhaps with an example?

darkagn 315 Veteran Poster Featured Poster

Ok, that's not what I meant but I see your point. What would happen in your example though if I typed in http://someurl/../includes/constants.php.inc into my web browser?

darkagn 315 Veteran Poster Featured Poster

Except you need to begin with a slash. Below is a corrected example of the above quote.

include("/home/includes/constants.php.inc");

That is incorrect. Your example is an absolute path, mine is a relative path, both of which are perfectly legal. However mine does rely on the path from where the script is being run whereas yours does not, so is probably a safer option.

darkagn 315 Veteran Poster Featured Poster

Can you post the code for your Record class? I suspect the answer might be that you need to override the Equals method, so if you haven't done that I would start there...

darkagn 315 Veteran Poster Featured Poster

You have three entries in your $_POST array that are themselves arrays. The addslashes function expects a string and can't parse the array. Try this to see what is going on:

if (isset($_POST)) {
echo "<pre>";
print_r($_POST);
echo "</pre>";

This will print out your $_POST array in a neat format and you will be able to see what the inner arrays are.

EDIT: By the way, you might want to delete the full code part of your previous post as it contains your mysql password!