Archive for July, 2010

please help me about this PHP program problem?

Hi i want to create a drop-down-list in PHP.
In yahoo answers’ home page there are some tabs like "MY activity" "browse categories" and these tabs have some sub tabs….so whenever mouse-pointer comes over these tabs so the sub tabs are displayed as a list….so how to do this…please help me please it is urgent.
ok but please give me the java code to resolve this problem…

You’d be better off using Javascript.

PHP has nothing to do with it.

Or you can try using css if you know what you’re doing.

Help! How do I do this in php?

I’m always getting tripped up in php because there’s no way that I know of to "call" or "run" from one php program to the next without form input.

I am collecting data on a Web form that needs to be passed to a server for processing. I have a form with action="calculate.php". When the user submits the form, calculate.php reads the form fields and does some calculations. This is where I need a "run" command. The calculated fields are to be processed by a program on the server. I don’t know how to fire off this program without another <form action=….> tag. In this case it’s stupid to have the user hit submit again just to send data to the server. There really isn’t anything for the user to review. And it’s not an option to do the calculations on the server because that’s a black box application (and I don’t have access to the server).

So the only way I can see it flowing is like this:

Enter data
Submit form
php program does calculations
Useless form appears
Submit form again
Server-side program does its thing

What am I missing here? Surely this has come up thousands of times.

Thanks,
Houyhnhnm
Deepak, I am totally ignorant in Ajax and very weak in JavaScript. I know how to do math in JavaScript but I have no idea how to pass the results to the server or the php script. I thought the whole idea of JavaScript was to keep everything local anyway…

can you use javascript to do calculations?
is it too complicated to do with client side ?
can you use ajax so that some other form does the calculation?

…………………..

if you can do math using javascript, then you can use hidden fields to send data to php script ..

i see that you say it is as a blackbox application, i wonder how can send input data to it. but hope you can use my suggestion..

ex: i assume that "F_Total" is input for your blackbox application! ( a post parameter for your application)

<input id="F_Tot" name="F_Total" type="hidden" />

( if you use "name" attribute in your html tag, you can get the value at php script after submit. this works in any server side languages)

do all calculations before you submit,

<script type="text/javascript">
function doyourcalculation(){
var result;
F_Tot = document.getElementById(‘F_Tot’); // find hidden field
.
.
.
calculations
result = 3 + 2;
.
.
if (result){ //if result is not nothing
F_Tot.value = result;
return true;
}
else
return false;

};
</script>

use return true or false for validations…
<input type="submit" value="submit" onclick="doyourcalculation()" />

if doyourcalculation has no error and returns true, hidden field has the input for your blackbox application.

good luck..

Where are the best places to learn programming skills quickly?

I want to learn how to use MySql, Php, BB code, and codes like those, but in easy and effective way. I have prior knowledge, so feel free to post slightly advanced links too.

That’s like a teen-ager asking how to be 50 years old quickly – you can’t do it quickly, whether it’s getting older or learning programming. To see what you’re asking for, read http://www-old.oberon.ethz.ch/WirthPubl/AD.pdf That’s the best programming course ever written. (No, I didn’t write it, and it’s free.) Figure on at least 6 months to get through that.

MySQL is a program, the language is SQL. Figure on a few months, at least, to learn the basics of SQL (the things that 95% of SQL programmers stop at). PHP is trivial once you know programming, you can "learn" it by keeping the php.chm file open as you work. BB code is about as difficult as learning to count to 10.

But learn programming first. If you want to build a house, you don’t learn "hammer", you learn carpentry. Don;t learn the tool (programming languages) until you’ve learned what to use tools for (programming).

Help With PHP Email Form – Attaching Files?

Hello
being a newbie in php programming field I would like to ask for assistance with e-mail form and attaching files. I have bought a template for website with included mailer form. The only problem with it is that it only allows to attach jpg files and i need word documents, pdf, and exel files as well as images to be attached and mailed.
Below is the script line from the form. Can someone please advise on how can i modify it in order to have word, exel, pdf and image files arrive to my email. Thank you

<? if($_POST) {
include(‘form_config.php’);
if(eregi(‘.jpg’,$_FILES[image][name])) {
$unid = uniqid();
move_uploaded_file($_FILES[image][tmp_name],’offer_uploads/’.$unid.’.jpg’);
$urla = "http://www.globalmeattraders.com/offer_uploads/$unid.jpg";

The code has been truncated, so it is difficult to tell you exactly what is going on…
But, it seems that the line:

if(eregi(‘.jpg’,$_FILES[image][name]… {

is checking whether the uploaded file is of the type .jpg
Whenever, a file is uploaded, the file info is stored in the $_FILES superglobal. You can access the type of the uploaded file using $_FILES[image][type].

So, in the above mentioned if condition, check what is happening. If it is just checking the file type, you can remove it and your code will allow other file extensions too.

Refer to the following link for more details:

http://www.php.net/manual/en/features.file-upload.php

I’m interested in becoming a veterinarian what courses should i take at my community college?

http://www.sussex.edu/academics/programs.php these are the courses i’m just curious in what I should be taking to hopefully advance to a 4 year college and then a vet school.

it depends on the school you want to transfer to. certain schools want certain classes.
speak to a counselor to get the exact answers you’re looking for. otherwise, you’ll just be taking classes and wasting your money on courses that your target school doesn’t accept.
you should see a counselor at least once a semester to make sure that you’re on track. most counselors work through the summer, so call your school and make an appointment. good luck!

CodeIgniter – Disallowed Key Characters

I ran into this issue recently and found that there was not many good answers on how to fix the issue. You first need to know what caused the error and Code Igniter doesn’t tell you. So I ended up modifying the core code to display the Characters in fault. This allowed me to immediately locate the culprit and fix it.

In the system/libraries directory there is a file called input.php

If you open that file and go to about line 200 you will see a line that says:

exit(‘Disallowed Key Characters: ‘);

It is in the function:
_clean_input_keys($str)

Modify that line to say:
exit(‘Disallowed Key Characters: ‘.$str);

Now the error will show you the sting at fault.