You could try looking at the error message...
$result = mysql_query($sql)or die("<br />Could not run query Reason: " .
mysql_error());
...that's what they are there for :-)
Ian
On 18/11/05, D. K. Wema <[EMAIL PROTECTED]> wrote:
>
> I've tried to make the following script work but it
> has totally failed. After many hours of frustration, I
> kindly ask anyone who can help to save my day. The
> script is supposed to insert data into the database
> (mysql). When I enter the data and press the submit
> button, the entered data disappears but nothing gets
> to the database.
>
> Here's the code:
>
> <?php
> include("include/dbconnect.php");
> if($submit)
> {
>
> $sql = "INSERT INTO $table (firstname, lastname,
> cpeyear, city, country, workplace, email, comments)
> VALUES
>
> ('$firstname','$lastname','$cpeyear','$city','$country','$workplace','$email','$comments')";
> $result = mysql_query($sql);
> echo "<br><br>Information entered into address
> book.\n";
> }
> else
> {
> ?>
>
> <form method="post" action="<?php echo $PHP_SELF?>">
> <table width="440" border="0" cellspacing="1"
> cellpadding="1">
> <tr>
> <td width="158">
> <input type="hidden" name="id" value="<?php
> echo $myrow["id"]?>">
> Firstname:</td>
> <td width="275">
> <input type="Text" name="firstname"
> size="30">
> </td>
> </tr>
> <tr>
> <td>Lastname:
> </td>
> <td>
> <input type="Text" name="lastname"
> size="30">
> </td>
> </tr>
> <tr>
> <td>CPE/KCPE Year:</td>
> <td>
> <select name="cpeyear">
> <option value="1968">1968</option>
> <option value="1969">1969</option>
> <option value="1970">1970</option>
> <option value="1971">1971</option>
> <option value="1972">1972</option>
> <option value="1973">1973</option>
> <option value="1974">1974</option>
> <option value="1975">1975</option>
> <option value="1976">1976</option>
> <option value="1977">1977</option>
> <option value="1978">1978</option>
> <option value="1979">1979</option>
> <option value="1980"
> selected>1980</option>
> <option value="1981">1981</option>
> <option value="1982">1982</option>
> <option value="1983">1983</option>
> <option value="1984">1984</option>
> <option value="1985">1985</option>
> <option value="1986">1986</option>
> <option value="1987">1987</option>
> <option value="1988">1988</option>
> <option value="1989">1989</option>
> <option value="1990">1990</option>
> <option value="1991">1991</option>
> <option value="1992">1992</option>
> <option value="1993">1993</option>
> <option value="1994">1994</option>
> <option value="1995">1995</option>
> <option value="1996">1996</option>
> <option value="1997">1997</option>
> <option value="1998">1998</option>
> <option value="1999">1999</option>
> <option value="2000">2000</option>
> <option value="2001">2001</option>
> <option value="2002">2002</option>
> <option value="2003">2003</option>
> </select>
> </td>
> </tr>
> <tr>
> <td>City:
> </td>
> <td>
> <input type="Text" name="city" size="50">
> </td>
> </tr>
> <tr>
> <td>Country:</td>
> <td>
> <input type="Text" name="country"
> size="50">
> </td>
> </tr>
> <tr>
> <td>Workplace</td>
> <td>
> <input type="Text" name="workplace"
> size="70">
> </td>
> </tr>
> <tr>
> <td>Email:
> </td>
> <td>
> <input type="Text" name="email" size="35"
> size="40">
> </td>
> </tr>
> <tr>
> <td>Any comments: </td>
> <td>
> <textarea name="comments" rows="5"
> cols="40"></textarea>
> </td>
> </tr>
> </table>
> <input type="Submit" name="submit" value="Submit
> information">
> </form>
> <?
> }
> ?>
>
>
> Thanks in advance,
> dk
>
>
>
> __________________________________
> Yahoo! FareChase: Search multiple travel sites in one click.
> http://farechase.yahoo.com
>
>
> Community email addresses:
> Post message: [email protected]
> Subscribe: [EMAIL PROTECTED]
> Unsubscribe: [EMAIL PROTECTED]
> List owner: [EMAIL PROTECTED]
>
> Shortcut URL to this page:
> http://groups.yahoo.com/group/php-list
>
>
> ------------------------------
> YAHOO! GROUPS LINKS
>
>
> - Visit your group "php-list<http://groups.yahoo.com/group/php-list>"
> on the web.
> - To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]<[EMAIL PROTECTED]>
> - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------
>
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
1.2 million kids a year are victims of human trafficking. Stop slavery.
http://us.click.yahoo.com/WpTY2A/izNLAA/yQLSAA/HKFolB/TM
--------------------------------------------------------------------~->
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/