473,881 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What stupid mistake have I done now?

142 New Member

When I press sign(submit) - It looks like something is wrong and the code does not want to insert the info into my SQL...I get the error message "could not query.." that I type in under "#create the sql query" I went trough the book I got the script from and check to see that all of the spaces and letter is exactly as it should be..I am still learning php and figure I made a stupid mistake that problem someone that is fluent in PHP will pick up directly.


$self = $_SERVER['PHP_SELF'];
$name = $_POST['name'];
$email = $_POST ['email'];
$comments = $_POST ['comments'];
$submit = $_POST ['submit'];

# the html form
$form = "<form action=\"$self\ " method=\"post\" >";
$form.= "Name: <input type=\"text\" name=\"name\" ";
$form.= "size=\"50\ " value=\"$name\" > <br>";
$form.= "Email: <input type=\"text\" name=\"email\" ";
$form.= "size=\"50\ " value=\"$email\ "> <br>";
$form.= "Comments:<br>" ;
$form.= "<textarea name=\"comments \" cols=\"45\" ";
$form.= "rows=\"4\">$co mments</textarea> <br>";
$form.= "<input type=\"submit\" name=\"submit\" ";
$form.= "value=\"Sign\" > </from>";

#on first opening display the from
if ( !$submit) { $msg = $form; }

#or redsiplay a message and the from if incomplete
else if( !$name or !$email or !$comments)
{ $msg = "<b>Please complete all fields</b><br><br>";
$msg.= $form; }

#or add the from data to the guestbook database table
else #otherwise connect to mysql
{ $conn = @mysql_connect( "localhost" , "webandwe_weban dwe", "mysql" )
or die ( "could not connect to database" );

#select the database
$rs = @mysql_select_d b( "webandwe_conta ct", $conn)
or die ("could not select database");

#create the sql query
if( $name and $comments )
$sql ="insert into guestbook (name, e-mail, comments)
values(\"$name\ ",\"$email\",\" $comments\")";
$rs = @mysql_query( $sql, $conn )
or die ( "could not execute SQL query" ); }

#confirm entery and display
if ($rs)
{ $msg = "<h3>thank you - your entry has been saved.";
$msg.= "<br><a href = \"guestbook-view.php\">";
$msg.= "View my guestbook</a></h3>"; }
#write the page
echo ( $msg );
Mar 14 '07 #1
0 992

Sign in to post your reply or Sign up for a free account.

Similar topics

by: news | last post by:
You'd think it'd be easier to find the answer to this question. Did a search, and all I can find is people asking why something's not working and people replying it's because register_globals is off. I found one person said: "The change is for the better since register_global turned to on had some grim security implications." but no mentioning of what those are! I'm working on a server now, with a couple hundred PHP pages someone has...
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
by: Materialised | last post by:
Hi, could someone have a look at the following code and the error message below, and point out where my error is, as I am having trouble figuring where I am going wrong. #include <algorithm> #include <iomanip> #include <ios> #include <iostream> #include <string> #include <vector>
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
by: Michael | last post by:
Hello everyone here, I've got a question according to a C program, but I'm not sure if this one is "off-topic". So, its a program using two structures each containing an array (a.array1 b.array2) Both arrays are of type double and of size 2x11. I access the structs via pointers (p_a, p_b). If I use
by: nick | last post by:
i do not know what is the use of (e.g. void *pt), when will use it. thanks!
by: MarkusR | last post by:
I am currently using StarTeam for my source control. (Will eventual switch to whatever the latest Visual Source Safe is going to be called). With debug, installers, deploy and everything the project directory structure is a mess of files and directories What files should be in source control (All final builds willbe done on anothe machine)?
by: Cromulent | last post by:
On 2008-07-06 21:09:55 +0100, Joe Wright <joewwright@comcast.netsaid: Err, no not really as that has nothing to do with stock market prices :). -- "I disapprove of what you say, but I'll defend to the death your right to say it." - Voltaire
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...
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,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Duprť who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.