answersLogoWhite

0

PHP Programming

Questions about the PHP programming language; How and when to use it, implementing techniques, debugging and handling errors, and general questions about PHP itself. For questions about software made with PHP, that do not deal with the manipulating, reading, or learning about the actual code, see the Computer Software category.

845 Questions

University solved slips for third year bsc computer science?

The university solved slips for third year Bsc Computer Science are usually issued after the students satisfy the conditions set out by the examination body. The students also have to meet the conditions set out by the senate.

How do you call JavaScript object in PHP?

You cannot do that, since PHP is serverside and javascript is clientside. The best way is usually to have an ajax layer (a php file) to handle requests from the main php file. For example: You would have 3 files index.php, ajax.php, and functions.js The index.php is what people would see, and would include the functions.js javascript file. The functions.js file would then send requests to ajax.php. These requests could be a search query, a login request, etc... or any other object for that matter. Accessing javascript objects on demand is not possible though.

Which browser is best for HTML and PHP developers?

PHP will work the same in all modern browsers, since it is a server-side script (meaning the code is executed on the server, rather than the user's computer).

HTML is slightly different as it is executed on the user's machine by the browser, and some browsers handle HTML differently. Some slightly older (and very old) browsers don't understand some HTML tags at all!

So in the case for HTML, the latest version of Chrome or Firefox would be your best option as both of these browsers support many or all HTML5 (the latest version of HTML) tags.

They also have developer tools so you can inspect your client-side code (HTML, JS, CSS, but not PHP) which might help you find out why something has gone wrong.

However, when developing don't forget that your audience might not be using the latest browser like you are, so they might get different results when they go onto your website! It's a good idea to have different browsers (and if possible, different versions of those browsers) on your machine to test your code in to make sure you get the same results every time.

How to create an on-line store using php codes?

Creating an online store from scratch using PHP is a complex and arduous task. One has to consider a number of variables, the most important of which is security. Unless you have a considerable amount of experience and a specific goal in mind, it might be better to use software that has already been created. There are many open-source (FREE) applications available such as OSCommerce and Zen Cart with generic options and some customization flexibility. If you have a larger budget and want a store that is completely customized for your brand and products, you may consider hiring the services of a professional creative design company such as California Creative Studios and allowing them to create one for you. If you are still set on creating your own, by all means, go for it! There are a number of useful tutorials out there on shopping carts, credit card processing, user rating systems etc. Study major online stores to get ideas for good design practices, and be sure to keep php.net open in a tab at all times. Good luck!

Three types of program errors and examples?

  1. Syntax errors: errors due to the fact that the syntax of the language is not respected.(The first type of error is a syntax error. You already know that syntax errors are caused when you don ' t obey the syntax rules of C#. A common syntax rule you might make in the beginning is forgetting to terminate each program statement with a semicolon.

    Intellisense does an excellent job of catching syntax errors. While you may hate the squiggly line

    that Intellisense displays, it ' s a lot easier for Intellisense to detect and isolate syntax errors than it is for you to do it yourself.)

  2. Semantic errors: errors due to an improper use of program statements.( Logic errors are those errors that remain after all the semantic and syntax errors have been removed. Usually, logic errors manifest themselves when the result the program produces doesn ' t match the result your test data suggest it should produce. Most of the time, logic errors are found in the Process . Logic errors occur when you implement the algorithm for solving the problem incorrectly.

    The key to fixing logic errors is to be able to reproduce the error consistently. A repeatable logic error is much easier to track down and fix than an error that appears to be occurring randomly. you will learn the details of using some of the tools Visual Studio provides to help you detect and isolate program bugs.))

  3. Logical errors: errors due to the fact that the specification is not respected(A semantic error occurs when you obey the syntax rules of the language but are using the statement out of context. For example, a sentence in English is expected to have a noun and a verb. Consider the sentence " The dog meowed. " This sentence does obey the rules of having a noun and a verb, but the context of the sentence is out of whack. Dogs don ' t meow, therefore the context of the statement is incorrect. The error message I showed you earlier:

    The name 'i' does not exist in the current context refers to a type of semantic error. There may well be a variable named i defined somewhere in the program, but it is not currently in scope. That is, you are trying to use i when it is out of scope.Intellisense does a good job of detecting semantic errors.)

Write a PHP program to check whether the number is palindrome or not?

This program only suits PHP. If you want a proper one try C program for it available on web

<body>

<?php

if(isset($_POST['submit']))

{

$text = $_POST['text'];

$string = mysql_real_escape_string($text);

$invert = strrev($string);

if($string == $invert)

{

echo "<br>Given number is a palindrome!!";

}

else

{

echo "<br>Given number is not a palindrome!!";

}

}

?>

<form method="post">

<input type="text" name="text" id="text" />

<input type="submit" name="submit" value="Submit" id="submit" onclick="<?php $_SERVER['PHP_SELF']; ?>" />

</form>

</body>

Can you sen a code to upload photo in javascript or php?

Please go to www.google.com, and search for "php upload photo script" or something alike. I'm sure you'll find somthing there.

How do you display a header image only on the homepage without using php?

There are many ways to do such a thing.

One would be to give the header a unique id on the home page and use CSS specify it's background image. Of course, if you're doing that, you might as well just add an image tag to it anyway.

If you're looking to add an image on that particular page, without modifying the element into which it's inserted, you could also do it using javascript:

<script type="text/javascript">

var URL = window.location.pathname;

var pageName = URL.substring(URL.lastIndexOf('/') + 1);

if(pageName == 'index.HTML'){

header = document.getElementById('pageHeader');

header.innerHTML = header.innerHTML + '<img src="headerimage.jpg">;

}

</script>

How do you create a simple questionnaire using php?

Here's a quick example on how to do it.

<?php if(isset($_POST['send'])) {

if($_POST['answer'] == 'My Answer')

echo 'You got it!';

else echo 'Wrong answer.';

}

?>

<form method="post" action="you_file_name_here">

What is the answer to this question?

<br>

<input type="text" name="answer">

<input type="submit" name="send" value="Check it!">

</form>

How do you make a library system in PHP?

Assuming that "a collection of useful functions" is the intended meaning of "library," this is essentially the same process in all languages. The primary difference from an application is that a library doesn't actually do anything; it only provides tools which other programs can use. To that end, you should ensure that your functions work for as wide a variety of use-cases as is practical. However, also be careful to not make the logic overly complex to support some corner cases.

You should first decide what the central purpose of the program is, and set about writing functions (and classes, in some cases) which satisfy that purpose. This can be done in at least two ways: by detailed pre-planning, or by quickly implementing everything according to the concept in your own head.

Detailed pre-planning is the better method (for any large program, not just libraries), but some programmers have difficulty designing a program on paper rather than in code. Even if you are unable to do this at first, try writing a simple mock-up and use it as a learning experience from which to draw ideas for your design document. Then start over, using the design document as a guide and repeat this process as many times as necessary. The primary benefit of this is that you will be less likely to get tangled up in conflicting ideas for how the program should work.

Alternatively, you can just start programming by the seat of your pants. This is commonly known within the programming community as "hacking." While it is more efficient than pre-planning for smaller bits of code, you will be more likely to write ugly, confusing code as the project grows.

In both cases, of course, proper programming style is essential. Write self-documenting code as often as possible, comment where this doesn't work, and document all functions, classes, class members, and (as necessary) global variables. And make sure to test everything frequently, perhaps setting planned features as milestones, after whose initial implementation you will run all tests to ensure that the new code didn't break old code.

Finally, very large projects are often separated into modules, which are locked from modification once they are completed. If a completed module must be modified to accomodate another, you should return to the pre-planning stage to produce a new design document, ensuring that the new implementation will be compatible with all the modules which already depend on the one to be modified.

How-to download php videos?

A PHP file will not be a video. Videos are commonly .wmv, .mov, .mp4, etc. PHP is a server scripting programming language. Since a PHP file is completely parsed on the server, you cannot download a PHP file, unless you use another script to enforce the download. But even that approach requires that the script be on the same server as the target one.

How do you use PHP?

The outline of PHP is rather simple to understand; developing projects in PHP is more difficult.

PHP, in a nutshell, is a language meant to output other languages, or plain text, depending on specific factors. PHP itself does not "display pictures" or anything of the sort -- it sends different languages (like HTML) to "display pictures."

The beauty of PHP is that everything it makes is what we call "dynamic;" meaning by visiting the same web page ran by PHP, it's possible to get something different every time (of course, that's set up by you).

For example, imagine you are on a website that incorporates PHP. This website asks you to log into an account you made earlier today.

  1. An HTML form is sent to the user
  2. The user submits the form, sending a username and password to the server
  3. PHP is the engine that checks if your username exists, and that the password you provided is correct
  4. If you logged in successfully, you will get some HTML stating so - sent by PHP. If the login failed (for example, you gave an incorrect password), you will get some different HTML.

Some understand PHP better than others, due to prior math and technology knowledge, and mere fate. Don't be discouraged if you cannot understand it at first - concept or syntax - as it isa difficult thing to grasp.

If you're still confused (which is perfectly reasonable!), visit the related links below. They have some excellent examples explaining the power of PHP and on writing your own PHP scripts.

You can use PHP for create various user friendly and search engine friendly web applications.

Will php 4.4.7 server support php 5 files?

Yes php 4.4.7 server support php 5 files. But most of the php 5 features are not supported by php 4.4.7 version

How do you add text to an already existing p tag in JavaScript or PHP?

Consider your HTML

<p id="pid">Hello </p>

In javascript

document.getElementById('pid').innerHTML="world";

Remember "id" are unique on the HTML page hence js will always pick <p> where id=pid.

What is dynamic programming language?

Dynamic programming languages are often refered to as 'weakly typed' which means that variables are not bound to a particular type until runtime. For example, C++ is a 'strongly typed language, while Perl is a 'weakly typed' or 'dynamic' language.

A strongly typed language requires that you specify a type:

int i = 0;

In that C++ snippet, an integer names i is created and assigned the value of 0. The following would not compile in C++:

int i = 0;

i = "Hello world";

This would fail because i has been declared to be an integer and can not be assigned a string value. The following code would succeed in a dynamic language like Perl:

i = 0;

i = "Hello world";

The type is not declared here at all, because it is not bound to a type until runtime. In the first statement, i is bound to an integer type but in the second statement it is bound to a string type.

While dynamic language are easier to program in, they are much slower than strongly typed languages and are generally regarded as less safe since checking is not done until run time.

How to get Crystal Report control in VB6?

What version of Crystal reports?

Assumptions:

  • If you have Crystal Reports installed on the development machine, then you will already have all the dll's required for your VB6 project.
  • You're using Crystal Reports v8 or v8.5.
  • You will name the crystal report object 'rpt'.

Configuring the project:

  • In your VB6 project, Select 'Project'->'Components' and check the checkbox for 'Crystal Report Control' and click 'OK'
  • Open the 'Form' view for the form you are coding and drag the 'Crystal' control onto the form.

Coding the project:

  • You can now reference the 'Crystal' object from within your code. Take note of the name of the report object, or change it to something useful.
  • Set the WindowTitle, Connect, ReportFileName and SQLQuery properties to values relevant to your setup.
  • Optionally, you can set the following values: (DiscardSavedData [I recommend setting this to True as it speeds things up in most cases; in fact, I recommend saving your crystal files without any saved data in the first place.], ProgressDialog, and if you have Formulas in the report that you wish to pass in, you can do so using the Formulas(x) property.
  • Once all properties are set, launch the report using the following code:

"rpt.Action = 1"

Sample code:

rpt.WindowTitle = Me.Caption

rpt.Connect = "[Insert ADO Connection String here]"

rpt.ReportFileName = sReportsDirectory + "\SomeReport.rpt"

rpt.DiscardSavedData = True

rpt.ProgressDialog = True

rpt.SQLQuery = "select field1, field2, field3 from tbl1 where field4 = 'Y'"

rpt.Action = 1

What is the TCP Reno algorithm?

TCP doesn't immediately acknowledge every single received TCP segment. If a

single segment is received it is necessary to wait for 100-200ms on the assumption

that the receiving application will probably generate a response of some kind. But

if there is delay in sending acknowledgement by the receiver then the network is

delayed.

Validating a form within Ajax tabs with PHP?

If you know jquery it will help to write javascript easily to accomplish, what is needed.

There should not be any difficulties because the form is inside a ajax tab.

if you will write on

$(document).ready(function(){

// here all validation should work

})

How do you call a PHP function from an onchange equals in an HTML form?

You would have to do this using an AJAX request. The onchange event would trigger a Javascript function that would in turn send a request to the server, and handle the response.

This requires a fair bit of back-end code for handling the AJAX, and I would recommend using an existing library for that purpose. jQuery is the one that I am familiar with, and you could handle that change event like so:

<?php

if(array_key_exists('mytext', $_POST)){

echo "The text you posted is "{$_POST['mytext']}"";

exit;

}

?>

<script src="(jquery source URL here)" type="text/javascript"></script>

<!-- ... -->

<input type="text" id="mytext"></input>

<div id="result"></div>

<script type="text/javascript">

$("#mytext").change(function(){

$.post("myscript.php", {'mytext':$("#mytext").val()}, function(dat){

$("#result").HTML(dat);

});

});

</script>

I'm testing out a mini social network type website how can I use php HTML or java script for other people to post images to their profile on my website?

Yes, you can allow file uploads to your site.

Add the file input to a form like this:


Select image to upload:


Make sure your upload.php has write permissions and then use the move() function to upload the file to your server:

$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);

if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";

}

w3schools has a great tutorial under PHP called PHP File Upload to help you with this exact thing

What is hibermate in computer programming?

You probably mean "hybernate"; that refers to a computer saving all contents of its memory (RAM) to hard disk, so that it can be turned off, kept off indefinitely without using power, then turned on again (and memory reloaded from the hard disk), to let the user continue right where he was. For instance, any documents that were open when the computer was hibernated will be immediately available after resuming.

How does open source products relate in a programming language?

We have two kinds of programming languages, Open Source and Close Source :)

Open Source like javascript and Close Source ":)" like .exe files (Compiled Files)

Open Source files like javascript wont be compiled and will be used as it wrote. if you think php is open source or not, i should tell you it's a different thing, the first thing you should be worry about is the security, javascript is open source and open source files are less or even unsecured files, it means everyone can see your source code, they can break down your security easily..

So what you should do? USE SOME ENCIPHER PROGRAM TO MAKE IT HARDER TO BREAK DOWN (it will just make it harder.. not impossible)

Close Source (Complied Files) are those that you write an code then it will be complied to something else to be understand by computers, like you write c# codes in Visual Studio and when you want to run it, your codes will be compiled to an exe application, then your computer will be able to run it.

Compiled Files is more secure but keep it in mind it don't mean it's unbreakable.. nowdays there are reverse programs out there.. :)

Wish i got your question right.. :)

How do you use the JavaScript confirm function in PHP?

It has to be done with Javascript. Though you could do something like this:
echo '';
?>