There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
MSSQL INSERT Need another set of eyes


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
msfdisk's Avatar
Member with 35 posts.
 
Join Date: Jan 2007
28-Feb-2007, 11:27 PM #1
MSSQL INSERT Need another set of eyes
Can some one look at my code here and tell me why I cant get the "refer" field to insert into the table when ALL the others are working?

$name = $_POST['Name'];

if(!@mssql_query("INSERT INTO a_UserDemographics (refer,UserId, FName, LName, MName, Password, Phone, AddressTypeCd, Addr1, Addr2, City, StateCd,ZipCode, CountryCd, Email, Fax,Mobile) VALUES ('$name','$userid','$fname','$lname','$mname','$password','$priphone','R', '$addr1', '$addr2', '$city', '$state', '$zip','$country','$email', '$fax','$cell')"));

<input name="Name" type="text" id="Name">

Is there a limit to insert using a single insert statement. I'm lost. I can get it to work on its own but not with other fields.....

UGH = I've been starring at this for 3 days trying to figure it out.

THX
msfdisk's Avatar
Member with 35 posts.
 
Join Date: Jan 2007
28-Feb-2007, 11:28 PM #2
MSSQL INSERT Need another set of eyes
Can some one look at my code here and tell me why I cant get the "refer" field to insert into the table when ALL the others are working?

$name = $_POST['Name'];

if(!@mssql_query("INSERT INTO a_UserDemographics (refer,UserId, FName, LName, MName, Password, Phone, AddressTypeCd, Addr1, Addr2, City, StateCd,ZipCode, CountryCd, Email, Fax,Mobile) VALUES ('$name','$userid','$fname','$lname','$mname','$password','$priphone','R', '$addr1', '$addr2', '$city', '$state', '$zip','$country','$email', '$fax','$cell')"));

<input name="Name" type="text" id="Name">

Is there a limit to insert using a single insert statement. I'm lost. I can get it to work on its own but not with other fields.....

UGH = I've been starring at this for 3 days trying to figure it out.

THX
Chicon's Avatar
Computer Specs
Distinguished Member with 6,598 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
01-Mar-2007, 01:32 AM #3
Like this :

Code:

if(!@mssql_query("INSERT INTO a_UserDemographics VALUES ('$name','$userid','$fname','$lname','$mname','$password','$priphone','R', '$addr1', '$addr2', '$city', '$state', '$zip','$country','$email', '$fax','$cell')"));
MMJ's Avatar
MMJ MMJ is online now
Distinguished Member with 3,208 posts.
 
Join Date: Oct 2006
01-Mar-2007, 03:27 AM #4
I need to see more code. Also please put it in [php][/php] tags, it makes it much easier to see.
Cookiegal's Avatar
Administrator with 53,596 posts.
 
Join Date: Aug 2003
Location: Quebec, Canada
01-Mar-2007, 09:42 AM #5
I've merged both threads together. Please do not start more than one for the same issue.
msfdisk's Avatar
Member with 35 posts.
 
Join Date: Jan 2007
01-Mar-2007, 11:57 AM #6
Chicon -
What did you do?
msfdisk's Avatar
Member with 35 posts.
 
Join Date: Jan 2007
01-Mar-2007, 12:03 PM #7
Here is some code:

<?

include('includes/dbConnect.php');
include('includes/functions.php');

//get the current timestamp
function get_current_datestamp(){
$currdate = gmdate("Ymd");
$currday = substr($currdate,6,2);
$currmonth = substr($currdate,4,2);
$curryear = substr($currdate,0,4);
$currdate_stamp = ($curryear . "-" . $currmonth . "-" . $currday);

return $currdate_stamp;
}
if($_POST['Submit']=='Submit'){

$fname = $_POST['FName'];
$mname = $_POST['MName'];
$lname = $_POST['LName'];
$addr1 = $_POST['Addr1'];
$addr2 = $_POST['Addr2'];
$city = $_POST['City'];
$state = $_POST['provState'];
$zip = $_POST['Zip'];
$country = $_POST['Country'];
$priphone = $_POST['PriPhone'];
$cell = $_POST['Cell'];
$fax = $_POST['Fax'];
$email = $_POST['EMail'];
$name = $_POST['Name'];

$code = $_POST['code'];
$dob = $_POST['dob'];
$password = $_POST['Zip'];
$sex = $_POST['Sex'];

//$datestamp = $currdate_stamp;

$trimmed_fname = trim($fname);//trim
$fname = strtolower($trimmed_fname);//convert to lower case
$fname_initial = substr($fname, 0,1);
$trimmed_lname = trim($lname);//trim
$lname = strtolower($trimmed_lname);//convert to lower case
$lname_initial = substr($lname, 0,1);
$trimmed_priphone = trim($priphone);//trim
$areacode = substr($trimmed_priphone, 0,3);//get the area code
$phone_7 = substr($trimmed_priphone, 3,7);//get the rest of the phone number
$userid = ''.$areacode.''.$fname_initial.''.$lname_initial.''.$phone_7.'';


$rs2 = @mssql_query("select * from a_UserDemographics where UserId='" . $userid . "'");
if(mssql_num_rows($rs2)){
$AddMsg = "This UserId Already exists!";
}else{
if(!@mssql_query("INSERT INTO a_UserDemographics (refer,UserId, FName, LName, MName, Password, Phone, AddressTypeCd, Addr1, Addr2, City, StateCd,ZipCode, CountryCd, Email, Fax,Mobile) VALUES ('$name','$userid','$fname','$lname','$mname','$password','$priphone','R', '$addr1', '$addr2', '$city', '$state', '$zip','$country','$email', '$fax','$cell')"));
$AddMsg = "The record has been added";
}



}//end submit

?>
msfdisk's Avatar
Member with 35 posts.
 
Join Date: Jan 2007
01-Mar-2007, 07:27 PM #8
bump - need immediate help please
Winona-Forever's Avatar
Computer Specs
Junior Member with 9 posts.
 
Join Date: Mar 2007
Location: Australia
Experience: Developer
04-Mar-2007, 09:33 PM #9
In the past, when I deal in lengthy, in-line SQL inserts, half the time they'll have some unknown problem which can be difficult to see to the naked eye. The best way of solving the issue is to just print or echo the suspect variables, or the entire SQL string...

For example...

PHP Code:
echo("INSERT INTO a_UserDemographics (refer,UserId, FName, LName, MName, Password, Phone, AddressTypeCd, Addr1, Addr2, City, StateCd,ZipCode, CountryCd, Email, Fax,Mobile) VALUES ('$name','$userid','$fname','$lname','$mname','$password','$priphone','R', '$addr1', '$addr2', '$city', '$state', '$zip','$country','$email', '$fax','$cell')"); 
...put that line in somewhere near the mssql_query statement, then have a look through what it prints.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:13 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.