You are here: Need help finding a bug... « PHP Programming Language « IT news, forums, messages
Need help finding a bug...

Posted by Anthony on 04/18/06 11:04

Hello Everyone,

I have been working with a piece of code for the past few hours that I
just can't seem to get working. I'm hoping someone here can help me
find the bug. Basically, the code is supposed to take all the data
entered into a forms fields, stripslashes() it then insert it into the
database. Pretty straightforward. The only thing that is unique is
that I am checking if a particular field is blank then allowing the
program to auto-assign a number to the field if it is. Still. pretty
straightforward.

What's happening, however, is that the information is never being
entered into the database. When I echo the sql statement being
constructed back it looks right. But I am sure there is a problem
somewhere. Can anyone help me find it? I will pay you $10 via paypal if
you can help me here. The code is below.

Thanks,
Anthony

if($_POST['fname'] != "" && $_POST['minit'] != "" && $_POST['lname'] !=
"" && $_POST['ssn'] != ""){

$fname = stripslashes($_POST['fname']);
$minit = stripslashes($_POST['minit']);
$lname = stripslashes($_POST['lname']);
$ssn = stripslashes($_POST['ssn']);
$phone = stripslashes($_POST['phone']);
$cdate = date("Y-m-j");
if($_POST['cnum'] != ""){
$cnum = stripslashes($_POST['cnum']);
}
else{
include("db.php");
$sql = "SELECT MAX(id) FROM clients";
$rs = mysql_query($sql);
$row = mysql_fetch_array($rs);
$cnum = $row['id'] +1;
}
include_once("db.php");

$sql = "INSERT INTO clients(' ', '$fname', '$minit', '$lname',
'$ssn', '$phone', '$cdate', '$cnum'";
echo $sql;
//exit;
mysql_query($sql);
echo "<font size=\"+1\"><b>ACCOUNT CREATED</b></font><br>";
echo "The new account for ".$fname." ".$minit." ".$lname." has been
successfully created.";
exit;
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация