Jump to content

Can anyone tell me why this query is not working?


DanielStead

Recommended Posts

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$sql_1 = "INSERT INTO SourceDocument (MapRef,Township,Parish,Dimensions,DateOfMap,Surveyor)

VALUES('$_SESSION['MapRef']','$_SESSION['Township']','$_SESSION['Parish']'

,'$_SESSION['SizeCM']','$_POST['DateofMap']','$_POST['Surveyor']')";

 

sorry its probably something really easy but this query works fine

 

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]

$sql_1 = "INSERT INTO SourceDocument (MapRef,Township,Parish,Dimensions,DateOfMap,Surveyor)";

 

so there seems to be something worng with my quieries but i cant spot it.

 

Link to comment
Share on other sites

Sure.. I think you have quoting issues for your column values; the second query just uses the default column values, so there's no problem.

 

'$_SESSION['MapRef']'

 

That's hard to parse -- where does the field value start & end? I see 4 single quotes -- and MySQL doesn't like them very much anyway. I would have broken out each hash key to keep from having to escape your quotes, which just looks horrible:

 

'".$_SESSION['MapRef']."'

 

Hope that helps.

Link to comment
Share on other sites

[!--quoteo(post=336976:date=Jan 16 2006, 12:09 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jan 16 2006, 12:09 PM) 336976[/snapback][/div][div class=\'quotemain\'][!--quotec--]

Sure.. I think you have quoting issues for your column values; the second query just uses the default column values, so there's no problem.

 

'".$_SESSION['MapRef']."'

 

Hope that helps.

 

the quoting issues is definitely the problem, and there are several ways to fix it... just choose whichever is easiest for you to view:

 

// this way
VALUES('{$_SESSION['MapRef']}','{$_SESSION['Township']}','{$_SESSION['Parish']}'
,'{$_SESSION['SizeCM']}','{$_POST['DateofMap']}','{$_POST['Surveyor']}')";

// or this way
VALUES('$_SESSION[MapRef]','$_SESSION[Township]','$_SESSION[Parish]'
,'$_SESSION[SizeCM]','$_POST[DateofMap]','$_POST[Surveyor]')";

// or the way mentioned above

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.