473,624 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

just trying to do simple site but no php hates me :(

the database looks like this

the database is called
username_tpp (not really just using username as a sub)
the table is called
home
it has
field 1 : varchar(50) | latin1_swedish_ ci | no attributes | null = no |
default = (nothing) | extra = (nothing) | action = primary key |
comments = h

field 2 : text | latin1_swedish_ ci | no attributes | null = no |
default = (nothing) | extra = (nothing) | action = text | comments = b

all i am trying to achive is to have someone post what they want to
appear on their website on this page as in the header and the body of
their site (i will do xhtml formating to make it look nicer if the
script ever works)

<?php // update_site.php
// This script adds a entry to the database.

// Address error handling.
ini_set ('display_error s', 1);
error_reporting (E_ALL & ~E_NOTICE);

if (isset ($_POST['submit'])) { // Handle the form.

// Connect and select.
if ($dbc = @mysql_connect ('localhost', username', password)) {

if (!@mysql_select _db ('username_tpp' )) {
die ('<p>Could not select the database because:
<b>' . mysql_error()
.. '</b></p>');
}

} else {
die ('<p>Could not connect to MySQL because: <b>' .
mysql_error() .
'</b></p>');
}

// Define the query.
$query = "INSERT INTO home (1) VALUE ('{$_POST['header']}')";
"INSERT
INTO home (2) VALUE '{$_POST['body']}'";

// Execute the query.
if (@mysql_query ($query)) {
print '<p>The blog entry has been added.</p>';
} else {
print "<p>Could not add the entry because: <b>" .
mysql_error() .
"</b>. The query was $query.</p>";
}

mysql_close();

}

// Display the form.
?>
<form action="update_ site.php" method="post">
<p>Page Header: <input type="text" name="header" size="40"
maxsize="100" /></p>
<p>Page Body :&nbsp;&nbsp;
<textarea name="body" cols="40" rows="5"></textarea></p>
<input type="submit" name="submit" value="Update My Website" />
</form>

i get this error...

Could not add the entry because: 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 '1) VALUE ('hello')' at line 1. The query was
INSERT INTO home (1) VALUE ('hello').

then i have another script that is not working
either which is:

this is the script for their home page that retirves the data that this
one posts into the table.

<?php // index.php
// This script retrieves header and body text from the database.

// Address error handing.
ini_set ('display_error s', 1);
error_reporting (E_ALL & ~E_NOTICE);

// Connect and select.
if ($dbc = @mysql_connect ('localhost', 'username', 'password')) {

if (!@mysql_select _db ('username_tpp' )) {
die ('<p>Could select the database because: <b>' .
mysql_error() .
'</b></p>');
}

} else {

die ('<p>Could not connect to MySQL because: <b>' .
mysql_error() .
'</b></p>');

}

// Define the query.
$query = 'SELECT * FROM home';

if ($r = mysql_query ($query)) { // Run the query.
>>>>this is not in the actual script but im sure this is where im going wrong<<<<<<
// Retrieve and print every record.
while ($row = mysql_fetch_arr ay ($r)) {
print "<p><h3>{$r ow['1']}</h3>
{$row['2']}<br />
</p><hr />\n";
}

} else { // Query didn't run.

die ('<p>Could create the table because: <b>' . mysql_error() .
"</b>.
The query was $query.</p>");

} // End of query IF.

mysql_close(); // Close the database connection.
?>

could you please help me ive been debugging for days now and my head is
going to explode

-thank you, philip (kirewire.com, leetmachines.co m, pealtech.com,
leetbargains.co m)

Nov 18 '06 #1
5 1469
kk*****@gmail.c om wrote:
the database looks like this
I responded to this post in comp.database.m ysql.

Please don't multi-post. If you wish to ask in multiple newsgroups,
please cross-post.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Nov 18 '06 #2
cross post? i did multipost cause i wasnt sure what group could help
the most... plus it gives me a better chance of getting a decent
response its not spamming a message board to get posts its to get good
info what if you werent going to show up in site design group for 2
weeks but showed up hear? eh.

Jerry Stuckle wrote:
kk*****@gmail.c om wrote:
the database looks like this

I responded to this post in comp.database.m ysql.

Please don't multi-post. If you wish to ask in multiple newsgroups,
please cross-post.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Nov 18 '06 #3
what i am trying to say here is

// Define the query.
$query = "INSERT INTO home (1) VALUE ('{$_POST['header']}')";
"INSERT
INTO home (2) VALUE '{$_POST['body']}'";

the name of the table is home
and that table whas two fields 1 and 2 and field 1 is a varchar 50 for
the header and field to is text for the body of my site and 'header'
and 'body' are the values im useing b/c those are the names of the
fields in the form

Nov 18 '06 #4
>what i am trying to say here is
>
// Define the query.
$query = "INSERT INTO home (1) VALUE ('{$_POST['header']}')";
"INSERT
INTO home (2) VALUE '{$_POST['body']}'";

the name of the table is home
and that table whas two fields 1 and 2 and field 1 is a varchar 50 for
the header and field to is text for the body of my site and 'header'
and 'body' are the values im useing b/c those are the names of the
fields in the form
1 and 2 don't look like field names. I also suggest you pick
something more descriptive. If you want them interpreted as field
names, you'll need to backquote them.

INSERT INTO home (`1`) ...
Nov 18 '06 #5
so many sites so little time wrote:
Jerry Stuckle wrote:
>>kk*****@gmail .com wrote:
>>>the database looks like this

I responded to this post in comp.database.m ysql.

Please don't multi-post. If you wish to ask in multiple newsgroups,
please cross-post.

--
============= =====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@att global.net
============= =====


cross post? i did multipost cause i wasnt sure what group could help
the most... plus it gives me a better chance of getting a decent
response its not spamming a message board to get posts its to get good
info what if you werent going to show up in site design group for 2
weeks but showed up hear? eh.
(Top posting fixed)

Yes. Cross posting is posting the same message to multiple groups *at
the same time*. This way messages from either group shows up in both.

Multi-posting is posting two messages (but the same text) to two
different groups. Multiposting is not spamming - but it makes things
very difficult to follow up. Also, people who don't read both groups
don't know what's going on in the other one.

I suggest you work with the messages in the mysql group. Right now this
is a problem with your SQL syntax, not PHP.

P.S. Please don't top post. Thanks.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Nov 18 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1600
by: Larry | last post by:
I am a C++/Java programmer trying to get going with some simpe xml transformations at work here. I bought the O'Reilly book Learning xlst for kicks. Someone at work sent me this xml shown below, they wanted me to try to output some simple text which summarizes the basic data in the xml and do it without perl. After that I guess they will want me to convert other xml files into some kind of text file I am assuming. I downloaded xalan, but...
40
3101
by: komone | last post by:
"Now is the time for all good web developers to use stylesheets". Hmm OK, so I start this commercial site design with the express intent of using CSS entirely. (Something I haven't attempted in about 3 years since I last wasted my time trying to get it to work). The site layout is intended to look (nearly precisely) like this from the CSS-2 spec: http://www.w3.org/TR/REC-CSS2/visuren.html#fixed-positioning
2
1378
by: spamfurnace | last post by:
Hi All, This thread may be a bit off topic and i apologise in advance to those newsgroups purists out there. But i wanted a little feed back from others in the same game as me. Below is my email of complaint regarding some service or lack thereof that i received from my a hosting service we just signed up too. Beneath that is the transcript of our conversation. If your a busy bee then stop reading now... its just me having a moan. I...
16
4541
by: LP | last post by:
Hello, I am trying to use .NET with Excel. I installed Office 2003 and selected ..NET programming suport option, so it installed all those PIA, as MS sugests. But I can not find a way to destroy Excel process, it still hangs in the taks manager' Processes as running. I am trying very simple code (see below), but Excel wont go away, I tried just about anything I could find on MSDN or by Google. Even calling WIN32 API to destroy Excel. But...
8
1486
by: Martin Randall | last post by:
Hi, I'm trying to get a simple dataview test page working on my hosted site. The hosted site runs ASP.Net 2.0, no problem. The test page works on my development machine, no problem... but when I upload the published site I get... System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings...
2
1036
by: sjol | last post by:
To the webmaster of python.org, I have tried to have a job posted on the job board but! Alas, it doesn't work and I cannot get a response from the webmaster. Shall I post here ? Stephane
23
1713
by: Sacred Heart | last post by:
Hi, I'm new to Python and have come across a problem I don't know how to solve, enter com.lang.python :) I'm writing some small apps to learn the language, and I like it a lot so far. My problem I've stumbled upon is that I don't know how to do what I want. I want to do a loop in a loop. I think.
5
2464
by: John Ladasky | last post by:
Hi folks, Running Python 2.5 on both a Windows XP laptop, and an Ubuntu Linux 7.04 desktop. I've gotten tired of maintaining multiple copies of my personal modules that I use over and over. I have copies of these files in the same directory as the main program I happen to be working on at the time. I've also downloaded FANN, and want to use its Python bindings. FANN does not seem to build automatically, like wxWidgets
25
2786
by: pereges | last post by:
Hello, I'm trying to build a database driven website for a library management system. The database is stored on a remote server which all of my team mates can access. I've installed MySQL, PHP and Apache on my machine. I'm a beginner and I really don't understand how to proceed. My biggest problem is how to connect to the database on remote mysql server ? Does php allow this kind of thing ? I'm interested in a web interface on my machine...
0
8236
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8173
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8475
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7159
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2606
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.