ShawnCplus 456 Code Monkey Team Colleague

Alright thanks for the quick answer!

And does the PHP need to run the socket server or are the C++ app supposed to do that?

Based on what you needed it would make sense for the C++ app to listen (be the server) and PHP to send the data to the server (client)

realchamp commented: Fast replies! +0
ShawnCplus 456 Code Monkey Team Colleague

Hmm the first one sounds like something I'd like to have, do you have any tutorials for that? (Both PHP and C++)

http://php.net/sockets

For C++ you might want to look around for forums, there's bound to be a link to a good one. If not, just google C++ sockets there is a veritable shit-ton

ShawnCplus 456 Code Monkey Team Colleague

There are a couple of ways to do it that pretty easy. If you're using the socket approach you can just have PHP open a client socket and send data to the C++ app. The other way is just to have C++ poll a file that PHP writes to. The latter is quite expensive but easier to implement.

ShawnCplus 456 Code Monkey Team Colleague

Develop an Inventory Control System. The database of inventory should keep the
information of Items in the file with flowing components,
a. Item ID
b. Item Category
c. Item Name
d. Last Date of Purchase
e. Cost Per Unit
f. Number of Items in hand
Include in your project add_new_Item, purchase, sale and show_item_detail
functions.

Wow, it's your second post and you still haven't read the rules. Bravo to you sir, that takes skill.

ShawnCplus 456 Code Monkey Team Colleague

You can do something like this

<form action="delete.php or whatever" onsubmit="return confirm('Are you sure?');">

That will pop open a box that says "Are you sure?" with yes and no buttons, if the user clicks no then the form won't submit and nothing will happen, if they click yes the form submits as it should.

Roebuc commented: Thanks! Sorry for the long wait on it though. +3
ShawnCplus 456 Code Monkey Team Colleague
int numbers[10];
for(int i=0; (i<10); i++)
{
  cout << "Please enter number " << i << endl;
  cin >> numbers[i];
}

cout << numbers[3];
cout << numbers[5];
cout << numbers[2];

Something like that?

Try not to spoon-feed him homework help considering he hasn't posted any attempts.

ShawnCplus 456 Code Monkey Team Colleague

ok
i've installed php5-cli
now what?

Now do the same thing, type php -v and paste the output here. If it says something like

PHP 5.2.6 (cli) (built: sometime)
Copyright (c) 1997-2009 The PHP Group
Zend Engine blah blah

Then you have it installed correctly and try what I said in my first post to get your script working on the command line

ShawnCplus 456 Code Monkey Team Colleague

oh, hahaha, did you also do sudo apt-get install php5-cli ?

ShawnCplus 456 Code Monkey Team Colleague

i have nothing on /usr/local/bin
i did sudo apt-get autoremove php5
then sudo apt-get install php5
still nothing...

type php -v on the command line and paste the output here.

ShawnCplus 456 Code Monkey Team Colleague

i am using ubuntu
and i've installed it like u said...
and still
nothing...
any idea?

type ls /usr/local/bin and if php isn't in that list then reinstall it.

ShawnCplus 456 Code Monkey Team Colleague

hi
thanks for your help!
is it

#!/usr/bin/env php

or

#!/usr/bin/env

because the first one doesnt work...

It's #!/usr/bin/env php and if that doesn't work then you didn't install php correctly. If you're using ubuntu or any debian distro it is just sudo apt-get install php5 .

ShawnCplus 456 Code Monkey Team Colleague

This will find the php interpreter for you and use it, don't directly link to it.

#!/usr/bin/env php
ShawnCplus 456 Code Monkey Team Colleague

Thanks to ShawnCplus. Solved.

<script type="text/javascript">
function submitForm(val) {
document.getElementById('submittedName').form.submit();
}
</script>

<form action="process.php" method="post">
<input type="hidden" name="hiddenName" id="submittedName" value="Jolly" />
<a href="#" onclick="submitForm('this.hiddenName');">SUBMIT</a>
</form>
<?php
echo $_POST["hiddenName"];
?>

That won't actually get you the value of the hiddenName element though. You would have to do document.getElementById('submittedName').value . But since you're not really setting the value anyway you can just remove the val argument altogether and remove 'this.hiddenName' from submitForm()

ShawnCplus 456 Code Monkey Team Colleague
ShawnCplus 456 Code Monkey Team Colleague

You have an extra , right before the WHERE

Will Gresham commented: Nice spot there :) +2
ShawnCplus 456 Code Monkey Team Colleague

If you get no errors and no exception is through but it's still a white page that means the query returned no results. Execute the query directly in MySQL or phpmyadmin or whatever you're using to directly access the database and see if it returns any rows.

ShawnCplus 456 Code Monkey Team Colleague
foreach $_POST as $key -> $value {
if ($value == 'Exit')
$echo $_POST['hiddename'];
}

Holy crap no. Just no. A thousand times no.

ShawnCplus 456 Code Monkey Team Colleague

Hello everyone,
please tell me how to disable print-screen option in mozilla firefox to save my web page.

You can't. Simple as that :) Even if you did disable it with javascript all the user would have to do is disable javascript and hit printscreen.

ShawnCplus 456 Code Monkey Team Colleague

It's the same for pretty much every browser.

document.getElementById('someidhere');
ShawnCplus 456 Code Monkey Team Colleague

xan, i read through that before i posted. still can't figure it out.

If you read through the FAQ then you would have A) Figured it out or B) posted the MySQL error that your are getting instead of just the error that says invalid argument.

So read through the FAQ again, and post the error that gets returned it should look like, "Error in MySQL syntax near...".

ShawnCplus 456 Code Monkey Team Colleague

It should be noted, however, that you can hack around it by not using an array but using an object like so

for ( i in ['key1', 'key2'])
  alert(i); // 1, and 2 respectively

// BUT

for ( i in {key1:0, key2:0})
  alert(i); // key1, and key2 respectively
ShawnCplus 456 Code Monkey Team Colleague

Hi,

We can code this way to print something if Exit button is clicked.

<form action="process.php" method="POST">
<input type="hidden" name="hiddenName" value="Jolly" />
<input type="submit" name="submit" value="Exit" />
</form>

if($_POST["submit"] == "Exit") {
   echo $_POST["hiddenName"];
}

What about if we use this way. How do i check if Exit button was clicked or not?

<form name="formExit" action="process.php" method="POST">
<input type="hidden" name="hiddenName" value="Jolly" />
<a href="#" onclick="document.formExit.submit()" title="Exit">EXIT</a>
</form>

if( ???????????? == "Exit") {
   echo $_POST["hiddenName"];
}

Thanks in advance

<script type="text/javascript">
function submitForm(val)
{
  document.getElementById('submitted').value = val;
  document.getElementById('submitted').form.submit();
}
</script>
<form action="process.php" method="post">
  <input type="hidden" name="submitted" id="submitted" value="" />
  <a href="#" onclick="submitForm('EXIT');">EXIT</a>
</form>
ShawnCplus 456 Code Monkey Team Colleague

No you can't. i in your scenario is the key for each value so the only way to get the actual value would to do ['val1', 'val2', 'val3'][i] which would defeat the purpose :)

ShawnCplus 456 Code Monkey Team Colleague

I was using num as an example. Forget about num, you're using num for your menu. You want to do it for each of your operations like this

else if (num == 1)
{
  int rad = -1;
  double pie = 3.14159;
  while (rad < 0) {
    cout << "Please enter in the Radius of the Circle ";
    cin >> rad;
  }
  double area = pie * (rad * rad);
  cout << "The Area of the Cirle is " << area << endl;
}
ShawnCplus 456 Code Monkey Team Colleague

Most hosts now-adays have a web-based apache log viewer in their control panels. If yours doesn't you might want to get a new host :)

ShawnCplus 456 Code Monkey Team Colleague

1. Develop sigma and pie bonding and anti bonding molecular orbitals of 2s and 2p

2. ???
3. Profit

ShawnCplus 456 Code Monkey Team Colleague

Well here

if (num < 1 || num > 4)

You're already checking if user input input is negative for the menu so just use that logic when you get input for the user's other values, for example

if (base < 0)
ShawnCplus 456 Code Monkey Team Colleague

You can't, the alert dialog uses the system's (or more accurately, the browser's) theme. If you want to change the way alerts look you will have to create your own modal dialogs.

ShawnCplus 456 Code Monkey Team Colleague

And considering Stroustrup invented C++ I'd consider it a good book

What? Are you mentally retarded?

s/good/accurate/

ShawnCplus 456 Code Monkey Team Colleague

I'm new to C++, and i've seen some C and C++ code.
I tried array[] and vector<> so i see i can use both, why should i use what way to work with vectors?
Furthermore, i've seen a lot of "array[]" in this forum... so, any lead?

Thank you!

Oh by the way, i'm learning with the "Principles and Practice Using C++" by Stroustrup, what do you think? I'm in the good direction? Any recommendations?

Well vectors are an expandable data structure whereas arrays are static. Once you define the size of an array it pretty much stays there (yeah, there are ways to increase them but not easily). Vectors were made to be expandable and best used when you have an undetermined number of items you need.

And considering Stroustrup invented C++ I'd consider it a good book though C++ The Programming Language is another good one from Bjarne

ShawnCplus 456 Code Monkey Team Colleague

What exactly don't you understand? You have a function 'hello' that takes 'name' as a parameter. Any time you call hello and pass it a value, in this case Daniweb it will use that value as the value of the parameter name.

function hello($name)
{
  echo 'Hello, ' . $name;
}
hello('Daniweb');

// is exactly like saying
echo 'Hello, ' . 'Daniweb';
// since the value of $name becomes 'Daniweb'
ShawnCplus 456 Code Monkey Team Colleague

A) This is not the C forum
B) You're using void main!
C) Stop using conio!
D) Don't use getch!
E) Use code tags

ShawnCplus 456 Code Monkey Team Colleague

My guess would be that they are case sensitive. In your HTML the ones that are saying undefined start with capital letters.

ShawnCplus 456 Code Monkey Team Colleague

You never close this if check

if (isset($_POST['submit'])) {
ShawnCplus 456 Code Monkey Team Colleague

no the carot negates it. itll remove everything that isnt an uppercase or lowercase letter hence the /i

You're right, it's been a long day :)
There's nothing really in that small block that limits how many items there will be in the array so it pretty much has to be elsewhere. As an aside, what is the trimthex for and where is the x coming from in the first place?

ShawnCplus 456 Code Monkey Team Colleague
$lowercaseusername = preg_replace("/[^a-z]/i", "", $lowercaseusername);

You do realize that'll remove any letter, whether it's uppercase or lowercase from the string, right? So ShawnCplus123 becomes 123 . Then your strtolower does nothing because there is nothing in the string except non-alpha characters. Remove the i off the end of the regular expression, that's telling it to be case insensitive so /[^a-z]/i is the same as /[^A-Za-z]/

ShawnCplus 456 Code Monkey Team Colleague

Oh that sounds great could you please provide an example or the code I would use so I can see how it is done?

Im really trying to learn all of this.

Thank you.

This isn't exactly what has to be done but it's a start. Take a look at w3schools.com for more javascript tutorials on opening windows

<script type="text/javascript">
var popupSomeWindow = function ()
{
  window.open('someurltopopup', 'someparams=hello');
  return false;
};
<a href="someurltopopup?someparams=hello" target="_blank" onclick="return popupSomeWindow();">Popup or new window</a>
ShawnCplus 456 Code Monkey Team Colleague

You could have the click be on an <a> tag with a target="_blank" which will open a new window. But if they have javascript enabled you can bind events to it with onlclick to open a popup and return false (to prevent the other window from opening;

ShawnCplus 456 Code Monkey Team Colleague

Hello all.
I have a string that will contain the username, for the security reasons i want it to be checked it if its diferent from the specific charset.
I think it could be done by looping the check 1 character from the username at a time till the end of it, but is there any faster way to do it?
For example:
$charset="abcd1234";
$string1="312";
$string2="5abc";
It should return that $string2 is not contained in the charset.
Thanks in advance.

http://php.net/preg_match That is all

ShawnCplus 456 Code Monkey Team Colleague

What's the error? (also, your code doesn't have an ending brace for the outer if)

ShawnCplus 456 Code Monkey Team Colleague

How about an intro to OOP - preferably without the 'everyday examples', perhaps something linked to login/members/profiles? I realize that's a biggie.

The thing that always gets me is regex. I $/.~ing hate it 'coz I can't get my head around it.

There's really no better tutorial for regular expressions that http://regular-expressions.info

ShawnCplus 456 Code Monkey Team Colleague

Your query might be failing

$result = mysql_query($sql);

Try

$result = mysql_query($sql);
if (!$result)
{
  echo mysql_error();
}
ShawnCplus 456 Code Monkey Team Colleague

He's contacted the owner of the machine, and they are not willing to reinstall php for him.

Nope, there isn't. GD has been built into PHP since 4.3 which is crazy-old. If the host isn't willing to update PHP then I'd say find a new host.

ShawnCplus 456 Code Monkey Team Colleague

Might want to take a look in your textbook or around the MySQL documentation before you start asking homework questions without showing work.

ShawnCplus 456 Code Monkey Team Colleague

Hi,

I am new to ajax and was taking look at code snippets.

Most of the code open and send are like this:

var client = new XMLHttpRequest();
 client.open("POST", "/log");
 client.send(message);

They open a connection and send the msg. Isnt connection open a costly call since the connection is set up over TCP/IP for HTTP? Why do we need to do a open each time? Wont the send go fine with the previous send session connection?

Bharath

If you use a Connection: keep-alive header then the browser would never know when the AJAX call is finished and you've never get data back. AJAX calls are fairly inexpensive unless you're sending insane amounts of data.

ShawnCplus 456 Code Monkey Team Colleague

You have to make an AJAX call to a server-side language which executes the command-line utility. Javascript can't access your server's filesystem directly.

ShawnCplus 456 Code Monkey Team Colleague

Wow, I can't believe I suggested that. That is insanely slow and stupid, sorry. Just do

$search = str_replace(' ', '%', $search);
ShawnCplus 456 Code Monkey Team Colleague

Line 49

if ($_POST["$submit"])
// should be
if (isset($_POST['submit']))
ShawnCplus 456 Code Monkey Team Colleague

what are those : and ? marks doing in there?

That's called the ternary operator.

$somevar = (condition) ? (true case) : (false case);
// so
$test = true;
$somevar = $test ? "Hello" : "Goodbye";

// is the same as
$test = true;
if ($test) {
  $somevar = "Hello";
} else {
  $somevar = "Goodbye";
}
ShawnCplus 456 Code Monkey Team Colleague

Well an HTML page is laid out like a tree.

/*
        HEAD
         |
        BODY
          \
           DIV  <-- SPAN's parent node
            \
            SPAN
            /  \
          A   IMG <-- SPAN's child nodes

Each point in the tree is called a Node. The Node directly above another in the tree is its parent (just like a family tree). Any node directly below another is a child