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

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

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

What does EOT mean?

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

$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 andym67 and welcome to DaniWeb :)

A better approach is this:

if(isset($_SESSION["namevalue"]))
   $val = $_SESSION["namevalue"];
else
   $val = "";
// maybe do some validation on $val here
echo "<input name='fname' type='text' class='textfield' id='fname' value='$val' />";

or:

<?php
if(isset($_SESSION["namevalue"]))
   $val = $_SESSION["namevalue"];
else
   $val = "";
// maybe do some validation on $val here
?>
<input name="fname" type="text" class="textfield" id="fname" value="<?php echo $val; ?>" />;
darkagn 315 Veteran Poster Featured Poster

Ah ok, so are all of your fields of type VARCHAR? Might be worthwhile changing to NUMERICs if you are going to be joining tables a bit, that is if that doesn't mess everything else up!

darkagn 315 Veteran Poster Featured Poster

I believe that IS the test. Just go through each of those 20 items and score yourself a 0,1 or 2 as the dude has said.

BTW I scored a 4 which I don't believe makes me saintly, just not psychopathic.

darkagn 315 Veteran Poster Featured Poster

Are you sure that your $_SESSION is set correctly? Try echo'ing your sql statement before you send it to mysql_query and see...

darkagn 315 Veteran Poster Featured Poster

So is $title the title of a single RSS feed item? If so, you can do something like:

$count = 0;
foreach($rssFeedItems as $title)
{
   if(empty($title))
      echo ++$count; // a prepend increment will add one to $count before it is used
   else
      echo $title;
}
lonestar23 commented: Great Coder! +2
darkagn 315 Veteran Poster Featured Poster

>If you specify an invalid language, it defaults to using the one from the
>current forum. csharp is now invalid in favor of C#. For c++, you can do
>C++ or cpp.

code=php is not working in the PHP forum.

EDIT: Just went back to get a screenshot to post, now it is working as before :$

darkagn 315 Veteran Poster Featured Poster

Hi Mujahid158 and welcome to DaniWeb

The mysql_query function returns a result set resource for select queries. You can't access it in the way that you are attempting, you need to specify the index of the resource. Like so:

echo $mem["username"];

For further information on the function, please see the documentation at www.php.net

darkagn 315 Veteran Poster Featured Poster

There are a few ways you can do this, but the simplest is probably to pass the variable via GET. To do this add the following line of code after you set $errorpas:

header("Location: User.php?errorpas=$errorpas");

Then at the top of your User.php script add the following lines:

if(isset($_GET["errorpas"]))
   $errorpas = $_GET["errorpas"];
else
   $errorpas = "";

// may need to perform some validation of what has been passed before you use it

If you google $_GET for php, you will get a better understanding of how to pass variables between php pages.

EDIT: I have assumed that you are trying to display the error message on the page User.php. If you are trying to display on Modify.php, change where I have written User.php to Modify.php.

darkagn 315 Veteran Poster Featured Poster

Not sure if this is your problem but have you restarted your webserver after installing the GD extension?

darkagn 315 Veteran Poster Featured Poster

I would have a single table, called user_pref, which would have the columns user_id, product_type_id, both of which would form the primary key for the table. If the user selects pets as a preferred option, add their user id and the pets category's id to the table. If the user then also selects the gardening category, add that to the table to.

When you display the items, check the table for preferences and if there is at least one row for their user id only display items in the categories listed, otherwise display items from all categories.

Hope this helps :)
darkagn

darkagn 315 Veteran Poster Featured Poster
$send="INSERT INTO mailbox SET
   member_id='$memid',
   user_name='$$_SESSION[user_name]',
   user_id='$_SESSION[user_id]',
   message='$message',
   inbox='NEW',
   subject='$subject',
   date='$dsub' " ;
$save_result=mysql_query($save);

What is $save? I think you are trying to run the query $send?

darkagn 315 Veteran Poster Featured Poster

Basically the way that it works is everything after the ? is a set of key-value pairs. So, if you need to find $_REQUEST["msg"] you need the URL to read http://xxxxx.php?msg=zzz

Hope this helps,
darkagn

darkagn 315 Veteran Poster Featured Poster

Hi Patrick,

Unfortunately it is not as simple as that. Different languages are better at different tasks. Most are designed to perform specific tasks at first and grow from there. Really what you need to do is work out what you are trying to achieve and then select the best tools for the job.

Hope this helps,
darkagn

darkagn 315 Veteran Poster Featured Poster
if(51 < $bal && $bal < 75)

This statement reads "if $bal is GREATER THAN 51 and LESS THAN 75". If you have $bal EQUAL to 51 it is not GREATER THAN 51. (Sorry for the shouting, but it is necessary to emphasise my point).

What you need is this:

if( $bal >= 51 && $bal < 75)

Similar for the rest...

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

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

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

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 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

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

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
<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 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

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

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

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

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

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

Upsilon is very close with that query. I will extend to give you the minimum value:

SELECT min(value) as value FROM table_name HAVING count(value) = 1
darkagn 315 Veteran Poster Featured Poster

Without access to the website's database I'm thinking this would be very difficult to do. What you are essentially talking about may have legal ramifications also.

darkagn 315 Veteran Poster Featured Poster

> Sorry about this, I really am at a loss with all this.
No need to apologise, that's why this forum is here :)

The foreign key in table t1 is definately referencing itself. And the field in question is also the PK of the table. This is very very very bad. What this says is "before you insert a new record, make sure that this record already exists!" Of course this is impossible.

My normal course of action here would be to drop the foreign key constraint from the table. Are you able to speak with whoever built the database to find out their intention with this foreign key? They might be able to tell you why they created it as they might have meant something else. Maybe they actually wanted to reference table t2's ID or something...

As I said earlier, backup the database, drop the constraint and see if this fixes your problem. Good luck :)

EDIT: And btw, table t2's FK constraint is ok.

darkagn 315 Veteran Poster Featured Poster

Are you able to check the FK on that table? You can do this at the mysql prompt like so:

mysql > SHOW CREATE TABLE t1\G

darkagn 315 Veteran Poster Featured Poster

So you are trying to insert to t1 and you get that error? I must admit I didn't think it was possible to have such a foreign key constraint as one that references itself. I think if that's the case then it would probably be best to drop the FK constraint from the table, just make sure you don't drop the primary key constraint if it is also the PK of the table.

EDIT: And remember to backup the database beforehand so you can go back if this is the wrong move!

darkagn 315 Veteran Poster Featured Poster

A foreign key constraint is used to stop you from inserting data into the table without a corresponding record existing in another table. The ID field in the table you are inserting into must match the ID field of a record in the table t1.

darkagn 315 Veteran Poster Featured Poster

table is the name of the table in the database. $database in your example will contain a result set of rows from the database according to the query passed into the mysql_query function. It should probably be named $result instead of $database to give you a clearer understanding of what is happening.

Try to think of a database being like a filing cabinet. The tables in the database are the files in the filing cabinet and store the actual data.

EDIT: To actually connect to the database in php, check out the mysql_connect function. Once connected you run SQL queries using the mysql_query function and interrogate the result with the mysql_fetch_* functions.

darkagn 315 Veteran Poster Featured Poster

Also, if you are receiving an SQL error, it may not necessarily be output to screen. Try this after you run your query:

if( $result == false )
{
  echo mysql_error( $link );
}

Again, $link isn't completely necessary, but just in case...

darkagn 315 Veteran Poster Featured Poster

1) Are you sure about spelling of "varchar"?
2) Have echoed query that is $update variable before executing then exectuted in phpmyadmin sql section?

Do not use dummy resolve actual query by echoing $update before exeuting in php.

1. I believe that is the name of his database, not a type of field.
2. I believe in his first post he has listed the actual query.

darkagn 315 Veteran Poster Featured Poster

4. I did not test "$result=true". Should I do this? I was under the impression that if "$result was not = true I would have thrown a php or sql error.

Yes, the documentation does seem to imply that. Maybe just try it to make sure?

This is certainly very strange. Maybe try explicitly stating the connection when you call mysql_query, like so:

$result = mysql_query( $update, $link );

Technically, $link isn't required usually, but maybe something weird is happening between the time you connect and the time you run your query. Sorry I can't be more help but as I say your code looks fine.