darkagn 315 Veteran Poster Featured Poster

ok

darkagn 315 Veteran Poster Featured Poster

Change $_GET[user] to {$_GET} (including the braces). An even better way would be:

$user = $_GET['user'];
if(strlen($user) == 0)
{
   echo "No user";
   die;
}
$query = "INSERT INTO friendrequest (username,by) VALUES ('$user' , '$by')";
darkagn 315 Veteran Poster Featured Poster

You are overwriting your $sql variable with the second statement. Try running the first SQL statement before you set the $sql variable, or you could change your second statement to use a new variable, for example $sql2.

darkagn 315 Veteran Poster Featured Poster

After years of coding all of a sudden I got a paper on "Authorization in instant messengers" to write. While creating a messenger and the authorization system isn't that big a deal, what can be written about it? It needs to be around 50 pages :/

So how would you go about creating the messenger and its authorisation system? I think that's all you need to do, 50 pages would include diagrams (UML for example) I would suggest...

PM me if you feel you could do the whole thing. I'm sure we can reach an agreement.

Cheats never prosper...

darkagn 315 Veteran Poster Featured Poster

There are two functions that you might find useful, in_array and array_search . Here is an example of their usage:

$employee = array();
$employee [] = array("name" =>"Chris Apple", "company" => "Acme inc.", "title" => "Developer", "salary" => "77000");
$employee [] = array("name" =>"Todd Orange", "company" => "Daves Dogs", "title" => "Mgr", "salary" => "177000");
$employee [] = array("name" =>"Gordon Banana", "company" => "Acme inc.", "title" => "Mgr", "salary" => "277000");
$employee [] = array("name" =>"Kim Pear", "company" => "XYZ Signs", "title" => "sales", "salary" => "77000");
$employee [] = array("name" =>"Steve Cherry", "company" => "self", "title" => "handyman", "salary" => "27000");
$employee [] = array("name" =>"Jay Pineapple", "company" => "Acme inc.", "title" => "sales", "salary" => "47000");

// in_array usage
foreach($employee as $record)
{
  $flag = in_array("Acme.inc", $record);
  // here $flag is true if the string is in one of the inner arrays of the $employee array
  // note that because we are comparing to a string, the in_array function comparison is case sensitive
  // there is a third optional (boolean) parameter that can be passed into the in_array method
  // and if set to true this causes the comparison to be strict (ie === rather than ==) but default is false
  echo "Acme.inc in record = $flag";
}

// array_search usage
foreach($employee as $record)
{
  $key = array_search("Acme.inc", $record);
  // here $key is equal to the first key (index) of the record that contains the string "Acme.inc"
  // in this example, for the first record, the $key will …
darkagn 315 Veteran Poster Featured Poster

I believe that Object one is your observer and objects two three and four would notify it when their data changes.

So Object one is your listener, the other objects are models in the explanation you gave above.

darkagn 315 Veteran Poster Featured Poster

Hi all,

I am fairly new to C# and WPF but I am super excited by the possibilities!

I am currently experiencing an interesting problem with my project. Basically I have a MediaElement that displays a series of videos or images with transition effects between each of them. When I display images, the memory usage of my PC ranges from between approx 80MB for a 70KB jpg image to 300MB for a 1MB jpg image, but when I display a 4MB wmv video the memory usage is around the 80MB range. My question is this: Is the MediaElement specifically optimised for video (which is really just a series of images?) and still images suffer performance hits because of this optimisation? Or is something else at work here?

I would be grateful for any insights you may have, and thanks in advance for any help.

Regards,
darkagn

darkagn 315 Veteran Poster Featured Poster

You can get the current timestamp from the time function and parse it to a date through the use of the date function. If you do this when the user logs in or out and store it in your database, you can then retrieve this information quite easily. Have a try and post an attempt, then we might be able to give you some more pointers.

darkagn 315 Veteran Poster Featured Poster

You can use a combination of the substr and strpos functions to achieve this.

darkagn 315 Veteran Poster Featured Poster

Hi nish123,

You will need to use two function calls for this, strtotime and date. First you use strtotime to convert your string to a unix timestamp, like so:

$time = strtotime( $date );

Then you use this timestamp to calculate a date in whatever format you want. To get the format yy-mm-dd, you need the following formula string: 'y-m-d'. So the call to date would look like this:

$myDate = date( 'y-m-d', $time );

For more details on these two functions, please see the documentation at http://www.php.net/manual/en. The documentation on the date function includes the common format strings that you can use to format your date.

darkagn 315 Veteran Poster Featured Poster

Can you post your code for generating the ticket number and displaying it please? This might help us figure out where you are going wrong...

darkagn 315 Veteran Poster Featured Poster

readData is not a public variable, so you can't access it by myInput.readData. Try this for your Input class:

class Input{
  private String readData;
  Input() throws Exception {
    readData = "";
    File inputFile = new File("/home/alias120/Desktop/School/CMIS 141/Project 4/input.txt");
    Scanner input = new Scanner(inputFile);
    while(input.hasNext()){
      String s1 = input.next();
      readData += s1;
    }
    input.close();
  }
  public String getReadData()
  {
     return readData;
  }
}

Then use Input.getReadData() to display your result.

darkagn 315 Veteran Poster Featured Poster

When you say you suck at math, how bad is it? Are we taliking about not knowing advanced calculus and algebra, or not knowing your times tables? Who are you comparing yourself to?

This site has lots of tutorials, demonstrations and explanations that might help you. I have used it often for some advanced concepts, but it starts at beginner and works through to the advanced levels of mathematics. There are many other sites out there aimed at online math learning, that's just the one I've used.

Good luck :) And remember, mathematics is actually fun when you get the hang of it (spoken like a true geek I know...)

darkagn 315 Veteran Poster Featured Poster

The way you have to think about PKs is how are the records in this table unique? Your first option says that each source will have one record on a given day (is this true?). The second one says every record is unique which of course is true but doesn't really say much about the record. Without really knowing what you are doing, I would suggest doing the following:
Columns: id, source_id, date, data.
PK: id, source_id
This allows each source to maintain a list of records within your table. Adding date to the PK is only useful if the records are individual on any day.

darkagn 315 Veteran Poster Featured Poster

The function array_search retrieves the key for a supplied value in an array if found, or false otherwise. This means that you can use it to search any array that does not contain boolean values. So, to search your array I would do the following:

$arr = array(1 => "apple",2 => "orange",3 => "mango");
$var = "apple 1";
$key = array_search( $var, $arr );
if( $key === false ) // note the use of identical rather than equal
{
  // not found, do something...
}
else
{
  // found, at index $key so
  $found = $arr[ $key ];
}

Note however that 'apple 1' is not in that array, so will not be found, because 'apple 1' does not equal 'apple'.

darkagn 315 Veteran Poster Featured Poster

If you are using a MySQL database, you can easily limit the returned results in a query with the use of the LIMIT function. For example:

$sql = "SELECT * FROM messages WHERE userId = $userId LIMIT(0,30)";

displays the first thirty records. If I had LIMIT(30,60) that would display the next 30 and so on.

If you don't have a MySQL database, try googling for an equivalent function in your preferred SQL engine.

darkagn 315 Veteran Poster Featured Poster

The easiest way to do this is to extend JPanel and override the paintComponent method. When you override the paintComponent method, you should do the following:

public void paintComponent( Graphics g )
{
  super.paintComponent( g );
  Graphics2D g2d = (Graphics2D) g;
  // use g2d.drawImage methods to paint your background image here...
}
darkagn 315 Veteran Poster Featured Poster

Hi martyulrich and welcome to DaniWeb,

Do you know what is meant by theta notation? If you show us that you understand the top-level theory we might be inclined to help you with the specifics...

darkagn 315 Veteran Poster Featured Poster

Good idea!
I've tried both things. In mySQL the query worked fine. However when I tried echoing the update statement everything was echoed (year,title, category) except autoid. It echoed $id, which means that autoid for some reason never is passed..

If autoid is a numeric field, you don't need the ' marks around it in the SQL statement. If you remove them, the $id should be resolved.

darkagn 315 Veteran Poster Featured Poster

Hi mveleli and welcome to DaniWeb :)

That's exactly what we're here for. Please post any questions you have and include some of your coding attempts and we will try to help to the best of our ability.

Happy programming!

darkagn 315 Veteran Poster Featured Poster

Also, you will need to check that each field has been set. Use the isset method on each of your $_POST retrievals, like so:

if( isset( $_POST[ 'title' ]))
  $titel = $_POST[ 'title' ];

Then you will need to qualify your SQL to only update the fields that are not null.

darkagn 315 Veteran Poster Featured Poster

Try echo'ing your update sql statement before you run the query. This way you can check the sql that is being run for the correct variables. Another good hint for debugging is to copy and paste that sql statement into an mysql command line and seeing what errors or results it gives you there (as opposed to php errors).

darkagn 315 Veteran Poster Featured Poster

Should it update the TITLE if you change the YEAR?

darkagn 315 Veteran Poster Featured Poster

Hi mr_vodka and welcome to DaniWeb :)

Love the username btw! :)

If all you want from the budget table is the budget_name field, you could just try this:

SELECT
fundinfo.fk_budget_ID,
fundinfo.fk_tiertwo_ID,
Sum(fundlink.fundlink_amt),
budget.budget_name
FROM fundinfo 
LEFT JOIN fundlink 
ON fundinfo.pk_fund_ID = fundlink.fk_fund_ID
LEFT JOIN budget
ON budget.pk_budget_ID = fundinfo.fk_budget_ID
WHERE fundlink.date_create <= '2009-03-15' and fundlink.date_create >= '2009-01-01' and fundinfo.fundinfo_budg_yr = '2009'
GROUP by fundinfo.fk_tiertwo_ID, budget.budget_name

Hope this helps,
darkagn

darkagn 315 Veteran Poster Featured Poster

Sorry what was your question? It seems to have been chopped because of the lack of spaces in it...

darkagn 315 Veteran Poster Featured Poster
<input type="hidden" value="$autoid">

The error is in this line, you have forgotten to name this field, so it can't find it in the $_POST array. Try changing to this:

<input type="hidden" name="autoid" value="$autoid">
darkagn 315 Veteran Poster Featured Poster

Hi ShawnCPlus,

Thanks for the super-fast response! That's what we were thinking, but I thought I would just post and get some outside opinions just in case.

Thanks again,
d

darkagn 315 Veteran Poster Featured Poster

>> You can google on Math.ceil() and Math.floor(). Math.ceil(double x) rounds x up to the next largest integer-equivalent number. So Math.ceil(1.5) returns 2.0. Math.floor(double x) rounds x down to the next largest integer-equivalent number. So Math.floor(1.5) returns 1.0.

These statements are a little misleading. Math.ceil() does not round the result, it returns the next highest integer. So Math.ceil(1.1) also returns 2. Similarly, Math.floor() returns the next lowest integer. So Math.floor(1.9) returns 1.

Ok, that said, your method is almost there I think. However, you shouldn't be calling Math.ceil on ounce*.17. You should be calling it on ounce and then multiplying its result by .17 unless I have misunderstood the problem at hand.

Hope this helps,
darkagn

darkagn 315 Veteran Poster Featured Poster

Hi all,

We are experiencing the following problem with the latest versions of IE and FF in regards to sessions. If anyone has encountered these problems before, any insight would be valuable.

In FF: An ongoing problem where sessions are saved across multiple tabs and windows in the same machine. This means that users that are logged in to one of our portals can open a new tab or window and be logged in here.

In IE7: Similarly, but different windows use different session data. However tabs are the same as FF.

In IE8: Ok, something really strange is happening here. Session data is saved on a domain basis for each window, so a new window behaves as a new tab would if it is in the same domain. On a different domain, different windows have different sessions, so the user is not automatically logged in.

These problems are mostly frustrating for the development team trying to debug across multiple portals. But we are starting to wonder if this is a security issue, and how we can work around it. Is this just a flaw in these browsers that web developers must accept, or has anyone come up with a suitable workaround for them? As I said before, your input will be appreciated.

Thanks in advance,
darkagn :)

darkagn 315 Veteran Poster Featured Poster

Do you want to create a separate forum for each language? Or do you want to translate the same forum to different languages? I think the latter would be much much harder...

darkagn 315 Veteran Poster Featured Poster

What a pleasant surprise she was!! :)

darkagn 315 Veteran Poster Featured Poster

Hi inazrabuu and welcome to DaniWeb :)

You can nest SELECT statements in an INSERT statement to get you what you need. For example,

-- insert into which table the values
INSERT INTO A.t (id, username, email, password) VALUES
-- from the other database
(SELECT id, username, email, password FROM B.t 
-- if they are not already in the other database
WHERE id NOT IN
(SELECT id FROM A.t))

This example assumes that the ID's match for the records in A.t and B.t, but you can expand it to suit your needs. Test this statement first be leaving out the first line of the above code and just selecting the records that will be inserted (ie just the nested SELECT statements).

darkagn 315 Veteran Poster Featured Poster

Hi Somerston and welcome to DaniWeb :)

You will need to join to the employee table twice to get the name for each column. Something like this should work:

-- first select the columns required
SELECT wo.id, em.name as submitted_by, emp.name as completed_by 
-- not sure if you can use these aliases
-- because they are also column names of the WorkOrders table
-- if not, rename them to submitted_name and completed_name for example

-- from tables
FROM WorkOrders wo
INNER JOIN employee em
-- link submitted_by to id of employee
ON wo.submitted_by = em.id
INNER JOIN employee emp
-- link completed_by to id of employee
ON wo.completed_by = emp.id
darkagn 315 Veteran Poster Featured Poster

One "drag and drop" PHP IDE that comes to mind is DreamWeaver from Adobe. I haven't used it much but from what I have seen I have liked, as it also allows you to create HTML, CSS, JavaScript and ASP files to name a few.

I would also like to agree with the previous posters in that such drag and drop IDEs are not necessarily good for you when you are learning the language. I still use PDT Eclipse regularly as I like to code PHP files by hand rather than using such tools.

EDIT: I believe that NetBeans is a Java IDE, not sure if there is a PHP plugin, but I would stick to PHP-specific IDEs if indeed you tread that path.

darkagn 315 Veteran Poster Featured Poster

Yes I have already mentioned that k2k can run their program as an applet. Do you know of any way that a java application (ie not an applet) can be run from an HTML link?

darkagn 315 Veteran Poster Featured Poster

Ah yes, good point. And I'm not trying to argue either, just trying to increase my understanding. Most of my recent programming has been in PHP, so just trying to keep my Java knowledge up to date. Sorry if I sounded argumentative.

darkagn 315 Veteran Poster Featured Poster

For that to work, your program must extend Applet. Also note that in Applets there is no main method, the Applet's init, start and stop methods are called instead.

There are also java servlet pages that allow you to display HTML pages in your browser from within a Java program, but from your description it sounds like you want the opposite.

I am unaware of any other way to run a Java program from an HTML page, anyone else have any ideas?

darkagn 315 Veteran Poster Featured Poster

Ok I haven't tested this, but here is what I was thinking:

public Number stackSum( Stack<Number> numbers ) {
  String className = numbers.peek().getClass().getName();
  if( className.equals( "java.lang.Integer" ))
  {
    int sum = 0;
    className = "int";
  }
  else if( className.equals( "java.lang.Double" ))
  {
    double sum = 0;
    className = "double";
  }
  else
  {
    // problem, should probably throw a NumberFormatException or something
  }
  for( Number i: numbers )
  {
    if( className.equals( "int" ))
    {
      sum += numbers.get( i ).intValue();
    }
    else
    {
      sum += numbers.get( i ).doubleValue();
    }
  }
  if( className.equals( "int" )
  {
    return new Integer( sum );
  }
  else
  {
    return new Double( sum );
  }
}

EDIT: Just saw BJSJC's last post - yes this code isn't generic but is polymorphic. I didn't realise that the requirement was on generic code, I thought that the original poster just wanted to have one method for both Integer and Double.

darkagn 315 Veteran Poster Featured Poster

No, that is not correct. You can return any subclass of Number if the return type is declared as Number.

If that is the case then I think my logic should work. If the method signature was like this:

public Number stackSum(Stack<Number> numbers)

Then I think it should be possible to have one method for both Integer and Double objects.

darkagn 315 Veteran Poster Featured Poster

You could have a hyperlink in an HTML page that links to another HTML page that contains a Java Applet. Not sure if that's what you are after though...

darkagn 315 Veteran Poster Featured Poster

So in Java you can't declare that you will return an object of type Number, but actually return an Integer or Double (since they are subclasses)? Is that correct?

darkagn 315 Veteran Poster Featured Poster

That's right - as I said "hope there's... no runtime cast errors" and after a bit more thought I'm even more convinced there is no sensible way to do what you ask. The only polymorphic way to do addition is via the + operator, that only works on primitives (int, double etc), but generics can only be reference types (Integer, Float etc)

I think that if you use Number class instead of T, you can call methods such as doubleValue() and intValue(), then use the + operator and finally return either an Integer or Double. Number is an abstract class that both of these classes extend, so the true polymorphic method of doing what is required would be to use a Stack<Number> and return Number.

darkagn 315 Veteran Poster Featured Poster

BzzBee there is an error in your sql.

SELECT username FROM id_users WHERE username='$username' and username='$refer_id'

username can only equal both $username and $refer_id if $username = $refer_id. Since people don't refer themselves, I think this is an error. Did you mean OR instead of AND?

darkagn 315 Veteran Poster Featured Poster

Well your error seems to be that you declare a variable called $end somewhere in that file in an unexpected place. I notice that you include a file called signup.php, but the error is in the file called sign_up.php? Might be worthwhile searching both files for the $end variable. Also, search login.php as well, especially if this contains inline code as I think it might from the logic of your displayed code.

EDIT: BzzBee, this is only the last few lines of the file, not the entire file, so we can't be sure what has come before it. From the looks of the second posted code, usang2me has fixed the misatching braces as suggested by xan and kokoro90.

darkagn 315 Veteran Poster Featured Poster

Hi to the DW tech staff.

I was thinking about the Location field in the public profile page for members as we have discussed it recently in this forum since it has been removed from the title bar for posts. Anyway I was thinking that it would also be handy to know if English is a member's first language. A field such as First Language and possibly one for additional languages spoken might be useful for those who take issue with people struggling to describe the problems they are having.

I have found the Location of a person handy for working out why people have spelling or grammar mistakes in their posts, but sometimes it can be misleading. Just because someone is from Chicago doesn't mean that English is necessarily their preferred language.

Anyways, just a suggestion.

Regards,
darkagn

darkagn 315 Veteran Poster Featured Poster

Can you re-post say lines 120 - 137 of the file sign_up.php for us to look at please?

darkagn 315 Veteran Poster Featured Poster

This is done in Apache server's .htaccess hidden file. If you google for information on how to change the settings in .htaccess you will find many examples.

darkagn 315 Veteran Poster Featured Poster

Hi nathenastle,

Please take the time to read the forum rules. In particular, how to post code using code tags.

In response to your problems, I don't really understand your question sorry. What do you mean by "the other mails getting decoded data"? If you uncomment $mime_boundary, your Content-Type line looks like this:

Content-Type: multipart/mixed;\r\n boundary="==Multipart_Boundary_x<32-bit encrypted number>"x

Are you sure this is what you want?

darkagn 315 Veteran Poster Featured Poster

Hi f0rb35 and welcome to DaniWeb :)

Here is a link to the MSSQL functions in the PHP Manual. Many of the functions correspond to similar MySQL functions, so it shouldn't be too hard to translate any of those MySQL tutorials to MSSQL.

Have a go, if you get stuck post back here with your attempts and we will try to help you out.

darkagn 315 Veteran Poster Featured Poster

Both the Integer and Double objects extend Number. So you could do the following:

public static Number sum (Stack<Number> stack) {

Note that this method will require you to check if the numbers are Integers or Doubles.

Also, remember that you can't use the + operation to add objects.