Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old April 15th, 2004, 07:56 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
PHP / MySQL INSERT not working

Amigos !!

Hello. I am having trouble with a very simple script. Could someone please look this over and help me out? I do have other script that I wrote more a tutorial that work fine, this one does nothing and writes nothing to the database. This just refreshes the page and writes nothing to the db. I get no errors or stops or anything.

Help me Obi wan etc etc

thanks,
starfruitman

using mac os x, apache, php 4.3.4, mysql 3.23, yourSQL


===
<HTML>
<?php
error_reporting(E_ERROR | E_WARNING);
//
$navigate=$_POST[navigate];
$desc=$_POST[desc];
$submit=$_POST[submit];
$update=$_POST[update];
//
if($_submit)
{
$db = mysql_connect("localhost","root","password")
or die ( mysql_error() . "n" );
mysql_select_db("learndyn",$db)
or die ( mysql_error() . "n" );
$sql = "INSERT INTO dyno (navigate, desc)
VALUES ('$navigate','$desc')";
$result = mysql_query($sql)
or die ( mysql_error() . "n" );
echo "Thank you! Information entered.n";
}
else
{
?>
<form method="post" action="<?php echo $PHP_SELF?>">
First name:<input type="Text" name="navigate"><br>
Last name:<input type="Text" name="desc"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?
}
?>
</HTML>

Reply With Quote
  #2  
Old April 15th, 2004, 11:28 PM
starfruitman starfruitman is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 starfruitman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: PHP / MySQL INSERT not working

FYI - you may get a SYNTAX ERROR in MySQL for using one of their RESERVED words as a variable or table column name. I figured this out the hard way. The word "desc" is one of them.

read on:

http://dev.mysql.com/doc/mysql/en/Reserved_words.html


Reply With Quote
  #3  
Old April 16th, 2004, 03:27 AM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
RE: PHP / MySQL INSERT not working

You can use backquotes for tablenames and fieldnames to solve this problem..

$sql = "INSERT INTO `dyno` (`navigate`,`desc`)
VALUES ('$navigate','$desc')";

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > PHP / MySQL INSERT not working


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway