Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

PHP mySQL Web Programming Interview Questions, Answers, and Explanations: PHP mySQL FAQ
PHP mySQL Web Programming Interview Questions, Answers, and Explanations: PHP mySQL FAQ
PHP mySQL Web Programming Interview Questions, Answers, and Explanations: PHP mySQL FAQ
Ebook191 pages2 hours

PHP mySQL Web Programming Interview Questions, Answers, and Explanations: PHP mySQL FAQ

Rating: 4 out of 5 stars

4/5

()

Read preview

About this ebook

The Ultimate Reference & Learning Guide for PHP mySQL!

100 Interview Questions, Answers, and Explanations

In order to stay competitive, today’s web programmer must have a thorough understanding of PHP and MySQL. With MySQL Interview Questions, Answers, and Explanations, you will be sure to stay up to date on the newest developments. Using this guide to prepare for a job interview or to brush up on the newest trends in MySQL will aid any web programmer in acquiring new skills and knowledge. This guide will explain many common errors, standard database maintenance, performance tuning, and many other new features. More than just documentation, this guide explains PHP and MySQL from the practical perspective of the web programmer so that you can evaluate a programming candidate or land that PHP mySQL position with ease.

Key topics include:

*SQL as a multithreaded, multi-user Database Management System
*Database interactions with Windows
*Database design, performance tuning, audit and security
*Database monitoring and maintenance
*Troubleshooting in implementation with ANSI C

LanguageEnglish
PublisherEquity Press
Release dateJun 3, 2011
ISBN9781603322089
PHP mySQL Web Programming Interview Questions, Answers, and Explanations: PHP mySQL FAQ

Read more from Equity Press

Related to PHP mySQL Web Programming Interview Questions, Answers, and Explanations

Related ebooks

Certification Guides For You

View More

Related articles

Related categories

Reviews for PHP mySQL Web Programming Interview Questions, Answers, and Explanations

Rating: 4 out of 5 stars
4/5

3 ratings1 review

What did you think?

Tap to rate

Review must be at least 10 words

  • Rating: 5 out of 5 stars
    5/5
    Mysql

Book preview

PHP mySQL Web Programming Interview Questions, Answers, and Explanations - Equity Press

Question 1: Printing a Document

Whenever I print an HTML page, the path of the page is printed together with the title. What should I do to avoid printing the path?

A: All you have to do is to make changes in the Headers and Footers setup of your browser. Go to File  Page setup  Headers and Footers and then make the necessary changes.

Question 2: Lostpassword.php Error

When I ran to test my script, I got the following error messages:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/hostvad/public_html/lostpassword.php on line 19

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/hostvad/public_html/lostpassword.php on line 24

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/hostvad/public_html/lostpassword.php on line 27

The script I tested runs this way:

Lost password

Content-Type content=text/html; charset=iso-8859-1>

#ffffff>

$v_sbm=$_POST['sbm'];

$v_username=$_POST['username'];

$v_email=$_POST['email'];

if ($v_sbm==Retrieve Password) {

require_once ('admin/authconfig.php');

$connection = mysql_connect($localhost, $hostvader_signup, $....);

$SelectedDB = mysql_select_db($hostvad_plussignup);

$result0=mysql_query(select distinct uname, passwd, email from authuser where uname='$v_username' and uname<>'admin');

while($row0 = mysql_fetch_array($result0, MYSQL_NUM)) {

$v0=$row0[0];

$u0=base64_decode($row0[1]);

$v_email=$row0[2];

}

$count = mysql_num_rows($result0);

if ($count==0) {

$result1=mysql_query(select distinct uname, passwd from authuser where email='$v_email');

while($row1 = mysql_fetch_array($result1, MYSQL_NUM)) {

$v1=$row1[0];

$u1=base64_decode($row1[1]);

}

}

if(($u0=='')&&($u1=='')) {

$flag=1;

$msg1= No username or email address matches, please try again.;

}

elseif ($u0<>'') {

$pass=$u0;

$username=$v0;

}

elseif ($u1<>'') {

$pass=$u1;

$username=$v1;

}

if ($pass<>'') {

//send email for lost password

$result=mysql_query(select subject,contents from emailtemplates where name='lostpass');

while($row = mysql_fetch_array($result, MYSQL_NUM)) {

$v_subject=trim($row[0]);

$v_message=nl2br(trim($row[1]));

}

$subject = $v_subject;

$headers = From: $v_emailfrom\r\n;

$headers .= MIME-Version: 1.0\r\n;

$headers .= Content-Type: text/html; charset=iso-8859-1\r\n;

$v_message = ereg_replace(\\<%username%>,$username,$v_message);

$v_message = ereg_replace(\\<%password%>,$pass,$v_message);

$v_message = ereg_replace(\\<%weburl%>,$url_root,$v_message);

mail($v_email, $v_subject, $v_message, $headers);

$getip=getip();

mysql_query(insert into log (uname,ctime,ip,activity) values ('$username',now(),'$getip','Send password to member($username).'));

$flag=2;

$msg2=Please check your email for the login information.;

}

mysql_close($connection);

}

function getip() {

if (getenv(HTTP_X_FORWARDED_FOR)) {

$ip=getenv(HTTP_X_FORWARDED_FOR);

}

else {

$ip=getenv(REMOTE_ADDR);

}

return $ip;

}

?>

 

form1 method=post action=lostpassword.php>

center50000#FFFFFF#ooooff

1 align= width= cellspacing= cellpadding= bgcolor= bordercolor=>

100%>

center>2 face=Arial color=#000080>


Lost Password

if ($flag==1) {

echo

$msg1





;

exit;

}

elseif ($flag==2) {

echo

$msg2





;

exit;

}

?>

center>#000099 size=2 face=Arial>To retrieve your password, please enter your

Login ID or Email Address


center67%00

0 align= width= cellspacing= cellpadding=>

33% height=15>

Arial size=2 color=#800000>Username:

67%>Arial size=2>text name=username size=27 value=--login ID-- style=border: 1px solid #808080; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1>

33%>

67%>

15 colspan=2 align=left>Arial size=2 color=#000099>OR

left>Arial size=2 color=#800000>Email Address:

left>Arial size=2>

text name=email size=27 value=--Email-- style=border: 1px solid #808080; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1>

2 align=center>

2 align=center

2 align=center>Arial size=2>

submit value=Retrieve Password name=sbm style=color: #800000>

center>

#999999 size=1 face=Verdana>Designed By #999999 size=1 face=Verdana>Easebay Resources


Could someone enlighten me on these error messages?

A: To find out the exact problem that is causing these error messages, add the line echo Mysql_error(); before the mysql_fetch_array() function and above mysql_query().

Question 3: Checkbox Array

I had a problem when I tried to use the check box array to delete multiple records from a table. Do I have to explode the values first before I try deleting the records? Could someone give me instructions on what to do?

A: It depends really on how you use the check box array while displaying records. Nevertheless, you can look at the page where you declare the check box name as array by using the following script:

checkbox name=test[] value=>

When you submit the page, you can find the checkbox array through the POST method using the script below"

foreach($test as $tempVal)

{

//Here u can perform the update or delete operation

}

?>

You will find this very easy to implement.

Question 4: Redirecting PHP Results to Calling HTML Page

I have an HTML page with hyperlinks on it with the name index.html. The page layout is shown below and the links are in TABLE 2. The Xs denote the shape layout of the table on the web page.

TABLE 1

xxxx

xxxx

xxxx

xxxx TABLE 2:

xxxx - link1

xxxx - link2

xxxx - getlist.php

TABLE 3

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx

The hyperlinks run/trigger PHP scripts. For example: getlist.php. The PHP script queries a MySQL database. The results are produced and then viewed on a new web page.

I want to imbed the results on the calling HTML page, i.e., index.html and I want them to appear in a specific location on that page. The specific location is in the same Table 2 but below the listing of the hyperlinks. For example:

TABLE 2

Link 1

Link 2

getlist.php

I want the results to appear in the following links in TABLE 2:

Link 1

Link 2

getlist.php

RRRRRRRRRRReeeeeeeSSSSSSuuuuuLLLttttSSS.

RRRRRRRRRRReeeeeeeSSSSSSuuuuuLLLttttSSS.

RRRRRRRRRRReeeeeeeSSSSSSuuuuuLLLttttSSS.

Below is my PHP code. I got the results to appear on the calling HTML page when I put the PHP INCLUDE code in the script but I cannot anchor them to the specific location.

index.html); ?>

$db_name = firstdb;

$table_name = table1;

$connection = @mysql_connect(servername, username, password)

or die(mysql_error());

$db = @mysql_select_db($db_name, $connection) or

die(mysql_error());

$sql = SELECT * FROM $table_name where city = 'washington' ORDER BY Name;

$result = @mysql_query($sql, $connection) or die(mysql_error());

while ($row = mysql_fetch_array($result)){

$Name = $row['Name'];

$Description1 = $row['Description1'];

$Address = $row['Address'];

$Telephone = $row['Telephone'];

$Email = $row['Email'];

$WebSite = $row['WebSite'];

$display_block .= "

$Name ($Address)

$Telephone ($Email) ( $WebSite )

";

}

?>

RESULTS

ResultsList

$display_block; ?>

Right now, the results appears as follows:

TABLE 3

xxxxxxxxxxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxxxxxxxxxxx

Here is where the results now appear:

RRRRRRReeeeeeeeSSSSSSSSuuuuuuuuuLLLLLLLttttttttttS SSSSS

RRRRRRReeeeeeeeSSSSSSSSuuuuuuuuuLLLLLLLttttttttttS SSSSS

RRRRRRReeeeeeeeSSSSSSSSuuuuuuuuuLLLLLLLttttttttttS SSSSS

How do I anchor the results into TABLE 2?

A: Assuming that you do not have problems in running PHP code within an .html extension, you could try to move up the PHP code and then add the line:

$display_block; ?>

In the line below Table 2, remove the $display_block

Enjoying the preview?
Page 1 of 1