This is my code -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
<title>Untitled Document</title>
-
</head>
-
-
<body>
-
<?php
-
-
if (isSet($_POST['name']))
-
{
-
$name=$_POST['name'];
-
}
-
if (isSet($_POST['age']))
-
{
-
$age=$_POST['age'];
-
}
-
if (isSet($_POST['phone']))
-
{
-
$phone=$_POST['phone'];
-
}
-
if (isSet($_POST['school']))
-
{
-
$school=$_POST['school'];
-
}
-
-
$connection =mysql_connect("localhost", "root", "") or die ("Could not connect to Mysql");
-
$selection = mysql_select_db('second') or die ("Unable select database");
-
-
$sql= mysql_query("INSERT INTO try1, try2 VALUES (name.age),(phone, school)");
-
?>
-
-
<?php
-
$sql = mysql_query("SELECT * FROM try1");
-
$sql1 = mysql_query("SELECT * FROM try2");
-
$result = mysql_fetch_array($sql);
-
$result = mysql_fetch_array($sql1);
-
while($result==0) {
-
print $result['$name'].$result['$age'].$result['$phone'].$result['$school'].'<br/>';
-
}
-
?>
-
-
</body>
-
</html>
-
after run, but why is in blank page
18 2683
because you have not turned error reporting on, and your code contains errors, such as
which should be written
lowercased.
As mark suggested you in a previous post, read the posting guidelines of the forum.
regards
In addition to bilibytes,
you should add link to functions like mysql_query() or mysql_select_db() (for example mysql_select_db('second', $connection);. Plus.. there's no reason to INSERT something to the database and then select it from there, you could just check if the INSERT went good or not, and then use the same variables... more then that, look at lines 37 and 38, if you run the 38, then then the 37 has no point because you're using the same variable name ($result), you just get something from the database and then override it with something else.
And the last thing, there's no point in: -
if (isset($_POST['name']))
-
{
-
$name=$_POST['name'];
-
}
You could just: -
$name = isset($_POST['name']) ? $_POST['name'] : false;
This is rather a strange observation
And the last thing, there's no point in: - if (isset($_POST['name']))
-
{
-
$name=$_POST['name'];
-
}
You could just: - $name = isset($_POST['name']) ? $_POST['name'] : false;
I know you are giving a tip but this more of a preference than an improvement.
Besides $name is handled differently if $_POST['name'] does not exist
Most languages execution speed improve by using ? operators.(For checking)
So i observer this by giving multiple if's and replaced it by ? operator.
Thats the only advantage i think.
Is it same case in php... I never tried it in php.?
@code green
As you said, I was giving a tip, and showing a person an alternative way, I usually prefer to use... :)
Dear, thz a lot, i ll try to fix it up.
Dear Canabeez
if i follow ur way to put as
$name = isset($_POST['name']) ? $_POST['name'] : false;
but it will come out an error Parse error: parse error, expecting `','' or `')''
so?
I generally use like this
So name is enclosed in the double quotes rather than single quotes.
Above code is working fine.
You replace your single quotes by double quotes and try.
I just don't think the ternary operator is good practice for a newbie.
The syntax is not as clear as if....else.
As for the performance, all benchmark tests I have seen produce miniscule differences.
Back to the problem. Your ternary syntax is correct dreamy.
The problem is elsewhere ie. isSet instead of isset.
But I suspect you have a missing bracket.
Your VALUES (name.age),(phone, school) will also not work
Dear, dheerajjoshim
if i put $name=$_POST ['name'];
and i hv try this before, but it will get the error of undefined index.
can i know why and ['name'] is the text name, rite?
And Dear code green,
i aldy change the isSet ti isset.
and, u hv suspect i hv missing bracket, can gv me the tips?
The last,
beside the undefined text error, i also hv
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #3' at line 1
can i know how to solve it.
thz.
very thx both of u
It's text filed name.
<input type="text" name="myname">
$name = $_POST["myname"];
Can't see any syntax error, check out the quotes, that must be it...
ok, i try to change my text name.
['name'] exact same wif my text file name.
thz ya, dheerajjoshim
That will not be a problem.
Your file name can be same.
ok, but how ro solve tat
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #3' at line 1,
can u help me? thz
I think you're sending the $Link instead of the $Query...
mean?
sending $Link instead of the $Query?
can tell me more? thz Canabeez.
- typeof $Link --> "resource"
-
typeof $Query --> "string"
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Rv5 |
last post by:
I have an assignment due mid next week that I have completed. I was hoping
someone could take a look at the code and tell me what they think of the
style. Id like to know if this is good code...
|
by: charlie_M |
last post by:
Is there a way to blank the screen in a FORM's onsubmit=... to blank
the screen for the user??
I asked this before and got a way to blank a table by id with
...
|
by: Melissa |
last post by:
Does anyone have a generic procedure for adding blank lines to reports like
Sales details, PO details and/or Orders details. The procedure would need to
count the number of line items, determine...
|
by: Nhmiller |
last post by:
Access seems to always generate a second page, which is blank, to my one page
report. How do I delete the second page? Thanks.
Neil
Cat Paintings At Carol Wilson Gallery...
|
by: noway |
last post by:
I have greated a report and have included a page break in it. The
report breaks were it is supposed to but then it creates a blank page
between the two pages. Since this report will print out...
|
by: bennett |
last post by:
At
http://www.brainjammer.com/testing/validator_test.aspx
I have a text field where you can enter text, and a button where if you
click the button, it sets the value of a label below it, to...
|
by: Wayne |
last post by:
I have a report containing 2 subreports. The subreports each contain a
chart. The whole thing easily fits on one page but a second blank page
is consistently being generated.
This has nothing...
|
by: siomay87 |
last post by:
please help
i have a problem in the ms access reporting,
my report have: page header, detail, page footer and report footer
In listing "detail section", the number of line is depend on the data...
|
by: sid |
last post by:
"about:blank" oepns new browser window
I am writing a webpage that will run on other machines that I may or
may not know about. My page is framed where frame1 controls the
content of frame2.
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |