ShawnCplus 456 Code Monkey Team Colleague

A) Invert that $_SESSION['username'] condition to just exit or something if it's not present instead of wrapping ALL of your code in an if
B) Use a bit more meaningful variable names than ij.
C) Assuming that $row has exactly 11 fields

// replace
      $index[$ij] = $row[0];
      $sdate[$ij] = $row[1];
      $sbranch[$ij] = $row[2];
      $svendor[$ij] = $row[3];
      $spo[$ij] = $row[4];
      $swriter[$ij] = $row[5];
      $sinv2[$ij] = $row[6];
      $sinvtotal[$ij] = $row[7];
      $spototal[$ij] = $row[8];
      $sinvduedate[$ij] = $row[9];
      $varience[$ij] = $row[10];
 // with
$vars = array('index', 'sdate', 'sbranch', 'svendor', 'spo', 'swriter', 'sinv2', 'sinvtotal', 'spototal', 'sinvduedate', 'variance');
  for($inc = 0; $inc < 11; $inc++) {
    $$vars[$inc] = $row[$inc];
  }

D) You're not ending your form tag, you're just opening another one

HITMANOF44th commented: a kick in the right direction +1
ShawnCplus 456 Code Monkey Team Colleague

Try the Linux forum

ShawnCplus 456 Code Monkey Team Colleague

Thanks for your reply. The script is written in PHP3 and what do I need to do to convert it to PHP?

That wasn't really my question. PHP3 is still PHP. My question is, what version of PHP is the server running on?

ShawnCplus 456 Code Monkey Team Colleague

Is the server using PHP3 or is the script just written for PHP3?

ShawnCplus 456 Code Monkey Team Colleague

Thanks a lot for the links. ArkM, and thanks a lot for the down-to-earth explanation, siddhant3s :).

So it is basically a way of saving myself for making overloaded functions, right? Or do they have another use? And I am assuming you can use templates in OOP too?

EDIT: And in your said function, would I be able to call it passing it two parameters of different variable type?

PS: Haha, thanks for the comment in my avatar. She is an actress.

Nope, while they are templated they are both of template type T meaning they have to be the same type. You could, however, do

template <typename T, typename Q>
T some_func(T arg1, Q arg2)
{
  return arg1 > arg2;
}

Though, obviously, the appropriate operator overloading would had to have taken place for it to work.

ShawnCplus 456 Code Monkey Team Colleague

>Does the ctor invoke undefined behavior or is it valid C++?
It's valid and required to initialize the data member y with the value of the parameter y. In the constructor body it's a different matter entirely, which is why you have to prefix the data member with this :

class X{
public:
  X(int y)
  {
    this->y = y;
  }
private:
  int y;
}

To add to Narue's post, they're called initialization lists if you want to research them on your own.

ShawnCplus 456 Code Monkey Team Colleague

I already read it, but it didn't really help me.

Not true, read it again. It answers your question exactly.

ShawnCplus 456 Code Monkey Team Colleague

Yeah, the problem is that PHP3 is 11 years old!. Are you serious, PHP3?

ShawnCplus 456 Code Monkey Team Colleague

Read the FAQ that is right above your post on the PHP forum

ShawnCplus 456 Code Monkey Team Colleague

Hi guys, I have a two functions in ajax; say for example the functions are...function AB() and function BC in my form I have a this textbox which calls the function AB() through onKeyUp event. I successfully made calling the said function, but what if I'll be calling the two function in a single event, is that possible?

Javascript, not AJAX. AJAX is something that can be done with Javascript. Javascript is the language.

ShawnCplus 456 Code Monkey Team Colleague

Other suggestions

That's pretty much it, there aren't a lot of full-featured web-based editors. They's slim pickin's as it were.

ShawnCplus 456 Code Monkey Team Colleague
"DELETE FROM email_list WHERE email = '$delete_id'";

Quotes

ShawnCplus 456 Code Monkey Team Colleague

lol yea i have uncommented it, still no luck. Thanks, i do appreciate the help

Ok, well repost your code because there is something wrong still.

ShawnCplus 456 Code Monkey Team Colleague

ok that seemed to work, but its still not deleting it from the database...thanks a lot for the help i appreciate it. The echo query shows that only one selected checkboxes email is shown at the end of the echo query command

stupid question, did you uncomment the part that is deleting? ie. remove the /* */. Also, you didn't put quotes around the email like I showed

ShawnCplus 456 Code Monkey Team Colleague

Mozilla Bespin Isn't too bad but I would suggest getting used to desktop editors. Relying on the cloud is a bad idea.

ShawnCplus 456 Code Monkey Team Colleague

Of course it's going to be empty, there is no ID field in the table. I'm going to assume you're using the email as the primary key, so change id to email in both the $row['id'] and changed WHERE id = $delete_id to WHERE email = '$delete_id' .

Also, edit your post to remove those emails.

ShawnCplus 456 Code Monkey Team Colleague

Hello everyone,
Does anyone knows any query expansion techniques that can be implemented using php other than hierarchical technique. i.e: facet , analysis, thesaurus.
By implementing query expansion, the users are not only presented with the keyword they inserted, but some related words to the keyword.

Thank you

If you're implementing a search engine purely in PHP you're doing something wrong. Take a look at Apache Lucene or alternatives along those lines. PHP can but shouldn't.

ShawnCplus 456 Code Monkey Team Colleague

http://davidwimbley.com/mysql/emaillist/removeemail.php

There is the link to the page

Your values are empty which means there is now id field in your table. var_dump($row); before you echo the <input> tag

ShawnCplus 456 Code Monkey Team Colleague

If you're getting empty values then $row['id'] is empty when you're writing the checkboxes. View the source of the page and make sure their values aren't empty. If they are the only explanation is that there is no "id" field

ShawnCplus 456 Code Monkey Team Colleague

Do the checkboxes show up on the form? And are you checking a checkbox when you test the delete?

ShawnCplus 456 Code Monkey Team Colleague

Ok, now post your form from which this is getting submitted to.

ShawnCplus 456 Code Monkey Team Colleague

Hey i hate to do this to you but i did the echo $query; and it displayed my query but it still did not delete anything.

this is what it displayed

DELETE FROM email_list WHERE id =

Which tells you what? That $delete_id is empty. Change the current

// Delete the customer rows (only if the form has been submitted)
  if (isset($_POST['submit'])) {
    foreach ($_POST['todelete'] as $delete_id) {
	$query = "DELETE FROM email_list WHERE id = $delete_id";
	mysqli_query($dbc, $query)
        or die(mysql_error());
    } 

    echo 'Customer(s) removed.<br />';
    }

to

if (isset($_POST['submit'])) {
  var_dump($_POST['todelete']);
/*
  foreach ($_POST['todelete'] as $delete_id) {
    $query = "DELETE FROM email_list WHERE id = $delete_id";
    mysqli_query($dbc, $query)
      or die(mysql_error());
  } 

  echo 'Customer(s) removed.<br />';
*/
}

and tell me the output

ShawnCplus 456 Code Monkey Team Colleague

>That is the "new" code under the comment:

Thanks,

Please mark this thread as Solved.

haha, I don't think (s)he actually had it solved, (s)he was just responding to my request to repost the new code.

ShawnCplus 456 Code Monkey Team Colleague

If you didn't get an error then it means it deleted the row. Before mysqli_query do echo $query; just to make sure it's deleting what you think it is deleting.

ShawnCplus 456 Code Monkey Team Colleague

Is it corrent?

SELECT FROM email .....

If this statement is select then he/she must have to include column list or *.

// Delete the customer rows (only if the form has been submitted)
  if (isset($_POST['submit'])) {
    foreach ($_POST['todelete'] as $delete_id) {
      $query = "SELECT FROM email_list WHERE id = $delete_id";
      mysqli_query($dbc, $query)
        or die('Error querying dHIHIHIHIHIHI.');
    }

That code will always fail because SELECT FROM is invalid MySQL syntax. The comment says that it should be deleted, all that has to be changed is SELECT to DELETE

ShawnCplus 456 Code Monkey Team Colleague

Ive changed the SELECT back to DELETE and have entered the die(mysql_error()) and now no error pops up. But its not deleting the record, it is still fetching the records out of the database.

When you tell us you changed code and you're getting a new error the smart thing to do would be to post the new code. We're not telepathic nor do we live in this here computer-box and can travel through the wires to see what you're doing.

ShawnCplus 456 Code Monkey Team Colleague

Was there an issue with the mail server because I didn't get any notification emails all weekend and all of a sudden it's spamming my inbox with about 5 emails every few minutes.

ShawnCplus 456 Code Monkey Team Colleague

The error being desplayed is this one here, i edited the display error so i could narrow it down.

I dont understand, if it can query the database and bring the rows of information and display it on the page, then why cant it delete it?

The connection string is the same for the other two scripts i have written and they work fine, the adding and sending email script

Thanks for the help

// Delete the customer rows (only if the form has been submitted)
  if (isset($_POST['submit'])) {
    foreach ($_POST['todelete'] as $delete_id) {
      $query = "SELECT FROM email_list WHERE id = $delete_id";
      mysqli_query($dbc, $query)
        or die('Error querying dHIHIHIHIHIHI.');
    }

Because as adapost said, you're not deleting with that query, you're just selecting. Changed SELECT to DELETE. And for future reference, when you're doing or die() on a query, don't put in arbitrary text do die(mysql_error()) (In other words, read the damn FAQ)

ShawnCplus 456 Code Monkey Team Colleague

<tr><th></th><th>$stat3[pID]

</th><td></td><td></td><td></td><td></td><td>$stat3[pName]

</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[pfName]

</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[village]</td><td></td><td></td><td></td><td>$stat3[dept]

</td><td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></td><td></td><td>$stat3[age]

</td><td><td></td><td></td><td></td><td></td></td><td></td><td>$stat3[sex]

</td><td></th><td></td><td></td><td></td><td></td><td>$stat3[tribe]</td><td></td><td></td><td></td><td></td><td></td><td>$stat3[symptoms]</td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[day]</td><td>$stat3[month]</td><td>$stat3[year]</td><td></td><td></td><td></td><td></td><td>$stat3[wgt]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[hgt]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[temp]</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>$stat3[bldp]</td></tr>

What the heck are you doing?!
Why, why, WWWWHHHHHHHHYYYYYYYY?. I'm not helping you until you explain this madness.

ShawnCplus 456 Code Monkey Team Colleague

what is wrong with that? - Well, a pure virtual function has no implementation itself, it forces the descendant classes to actually implement it so calling it would obviously toss an error.

how can I avoid it? - Make sure whatever class you're passing to whatever method that is calling the virtual method actually implements that function IE., if the method is supposed to take a Vehicle which has a pure virtual method move() make sure you're only passing it a descendant class like Car or Boat (in other words, classes that actually implement Vehicle 's method move()

ShawnCplus 456 Code Monkey Team Colleague

Thanks for the response but i actually have tried that and i still get a connection error. Any other thoughts?

If you get a connection error than it's not the query that is wrong.
What EXACTLY is the error being displayed to the page?

ShawnCplus 456 Code Monkey Team Colleague

alright..i put the code tags and the table appeared with the random numbers. but the box that is suppose to show the max numbers does not appear. how else would i get the program to work without using the the function again the second time?

I meant use code tags in your post, not in your code. Take a gander at the PHP manual and come back once you have a grasp on how functions work. http://www.php.net/functions

ShawnCplus 456 Code Monkey Team Colleague

Well there's a whole lot wrong. A) You didn't use code tags, B) You're using global instead of passing arguments to the functions, C) You're duplicating a function for no reason, D) You're not taking advantage of built-in language functions http://www.php.net/arrays

ShawnCplus 456 Code Monkey Team Colleague

This depends on the database engine you're currently using. By default MySQL uses MyISAM (Also uses MyISAM internally). However, MyISAM only supports table-level locking so when you're writing it locks the entire table. InnoDB on the other hand uses row-level locking along with a host of other features like foreign key constraints

ShawnCplus 456 Code Monkey Team Colleague

If you're abstracting it like that then drawer class shouldn't even need to know what a shape is. It just receives and acts on data. So you wouldn't want to actually pass a shape to that function, you'd probably want to pass coordinates to draw or something along those lines. It's not the Drawer class's job to figure out what to draw, it just draws.

ShawnCplus 456 Code Monkey Team Colleague

That's what I did before I posted here, and it didn't work. If you could just explain what you said in human english, maybe it is what I'm looking for.

And at the moment, I'm using typeid(*ptr) to determine what type it is.

http://en.wikipedia.org/wiki/Liskov_substitution_principle If you have the following class structure:

Shape
         /     \
   Square       Circle

Then you see that Circle and Square are both Shapes so if you have Shape::drawShape(Shape* s) then it will work on both Square and Circle since, as I said before, they are shapes.

However, this brings me to the point about why you wouldn't have a method drawShape(Shape* s) in your Shape or any descendant Shape classes. You'd have a Shape::draw() that acts on this . In OOP you should write your methods as if they are actions that object can perform on itself.

You could extrapolate this point further to preserve separation of concern by having Shape::draw() be a wrapper for a ShapeDrawer::draw(Shape* s) where you have a secondary class who's only job is to draw whatever shape it's given. But this is an different problem entirely.

ShawnCplus 456 Code Monkey Team Colleague

There's only one "guideline" to avoiding that error. Don't output anything to the page (be that echo, print, print_r, var_dump, etc.) before you call header()

ShawnCplus 456 Code Monkey Team Colleague

Hey, there is a difference in the number of arguments. So if you pass the required number of arguments, the corresponding function will be evaluated.

Overloading is not the same as polymorphism

ShawnCplus 456 Code Monkey Team Colleague

If you classes all extend SHAPE then drawShape(SHAPE* s) will work because of liskov substitution

ShawnCplus 456 Code Monkey Team Colleague

when i said im new to programming, i ment im new and only 15 years old that is serious about giving this ago, if you would be kind into show me where? thank you.

The only output statement in your code, the hint would be that it has the word "out" at the beginning.

ShawnCplus 456 Code Monkey Team Colleague

I've seen a lot of strange code but I've never seen someone accidentally write Duff's device

ShawnCplus 456 Code Monkey Team Colleague

Hi
I am trying to modify a class and I found this code in it:

$query = " SELECT * FROM menus WHERE show = '1'";
        
        $id = $this->menuid;
        
        if((isset($id)) && ($id != ''))
        {
            $query .= " and menuid in($id)";
        }
        
        $query .= " ORDER BY menuorder ASC";
        
        $result = $db->query($query);

        while($row = $db->dbarray($result))
        {
            @extract($row);
            
            if(($checkuser == 1) && ($_COOKIE['mid'] != $var['Guestid']))
            {
                $menu .= $this->$menutitle();
            }
            elseif(($checkuser == 2) &&  ($_COOKIE['mid'] == $var['Guestid']))
            {
                $menu .= $this->$menutitle();
            }
            elseif($checkuser == 0)
            {
                $menu .= $this->$menutitle();
            }
        }

what does "$this->$menutitle()" refer to? and how does it work? To my understanding you can not put a $ sing after "->" in a class. $menutitle() does not seem to me as a variable neither as a function. What am i missing?

That is a variable property in the same why variable variables are created. For example:

// variable variable example
$var = "hello";
$hello = "world";
echo $$var; // world
// variable property example
class TestClass
{
  public $hello;
  public function __construct()
  {
    $this->hello = "World";
  }
}

$test = new TestClass();
$var = "hello";
echo $test->$var; // world

See http://us2.php.net/manual/en/language.variables.variable.php

Airshow commented: Useful info - in the category "I should have known that but didn't" +1
ShawnCplus 456 Code Monkey Team Colleague

Will you people PLEASE read the date on the last post before you bump year old threads, this is getting really, really annoying and it's been happening a lot lately.

ShawnCplus 456 Code Monkey Team Colleague

Oh I am in my own little world, don't mind me :P.

I haven't taken much of a look at PHP5. Not sure if it is the version but the shit with all of the arrows, make my neck crawl. It seems pointless.

That "shit with all of the arrows" is OOP, you'll pretty much have to learn it to work on any PHP newer than version 4. Do a few google searches on imperative vs object oriented programming and you'll have your answer to whether or not it's pointless

ShawnCplus 456 Code Monkey Team Colleague

yes yes. Could somebody just give
a proper answer?
Php.net hould have its own guides
for this. :-/

Read every detail of http://us3.php.net/manual/en/features.commandline.php (Read the comments too)
PHP CGI is used as a last resort, mainly because of the configuration pain in the butt.

ShawnCplus 456 Code Monkey Team Colleague

http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html Use the language documentation before going to the forums please.

ShawnCplus 456 Code Monkey Team Colleague

Please look at the dates before posting, there have been a lot of 1 year+ bumps lately.

ShawnCplus 456 Code Monkey Team Colleague

NowDoc is takening over? or being included with HereDoc?

So you would only use NowDoc for a long line of text otherwise u would just use a variable and concactenate it with a period?

NowDoc is going to be separate of HereDoc. They'll serve two different purposes like "" and ''

ShawnCplus 456 Code Monkey Team Colleague

Listen to Shawn! However, am I right in thinking that it only works with php5.2 and above? This function is especially useful for ajax when a set of values need to be returned from a php script. I think there's a module for previous php versions.

It's default in 5.2 but is a PECL extension that can be used in older versions (Check http://pecl.php.net for details about it)

ShawnCplus 456 Code Monkey Team Colleague

Thanks all, for your input..
I have tried all but none is success..the same error still appear on the same line.

thanks

Then show all of the code, not just one line.