data is not being update

Light Poster
3Nov2006,12:42   #1
zeal's Avatar
when insert data in the GUI which is connected with mysql from php..
it is not being updated, meanzz when i open the page insert.php and insert the required data like..

Heading :- hello world
Description:- text

but when i submit, the data is not inserted in database. but database do update..

but when i insert only

Heading: Hello World
Description : <<nil>>

Bingoo! also database is updated...and heading do insert in it.

help me what is the problem behind this..
Team Leader
3Nov2006,16:55   #2
pradeep's Avatar
Please post the source code, so that I can look for the bug.
Light Poster
3Nov2006,19:35   #3
zeal's Avatar
add.php
Code:
<?
<html>

<head>
<style>
   <link rel="stylesheet" type="text/css" href="../misc/css1.css">
</style>

<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>International Cricket News</title>
</head>
<script language="JavaScript">
		function validateForm(objForm)
		{
			if (objForm.nhead.value == '')
			{
				alert('Please Enter A News Heading!!!');
				objForm.nhead.focus();
				return false;
			}
			else
			return true;
		}	
</script>
<body>
<hr>
	<font face=arial size=4>
		<b> News</b><br>
		<br>
</font>
<form action="insertnews.php" method="post" onSubmit='return validateForm(this);'>
<table border="0" width="100%">
  <tr class="smallfontblack">
    <td width="17%">Heading<sup><font color=red>*</font></sup></td>
    <td width="83%"><input type="text" name="nhead" size="100" maxlength=255 class="input_ns"></td>
  </tr>
    <tr class="smallfontblack">
    <td width="17%">News Message</td>
    <td width="83%"><textarea name="nmsg" cols="100" rows="10" class="input_ns"></textarea></td>
  </tr>
   <tr class="smallfontblack">
    <td width="17%">ScortBord Link<sup><font color=red>*</font></sup></td>
    <td width="83%"><input type="text" name="score" size="30" maxlength=255 class="input_ns"></td>
  </tr>
   <tr class="smallfontblack">
    <td width="17%">Live Match Link<sup><font color=red>*</font></sup></td>
    <td width="83%"><input type="text" name="lmatch" size="30" maxlength=255 class="input_ns"></td>
  </tr>
   <tr class="smallfontblack">
    <td width="17%">Rating Link<sup><font color=red>*</font></sup></td>
    <td width="83%"><input type="text" name="rlink" size="30" maxlength=255 class="input_ns"></td>
  </tr>
   <tr class="smallfontblack">
    <td width="17%">Other Link Title<sup><font color=red>*</font></sup></td>
    <td width="83%"><input type="text" name="olinktit" size="20" maxlength="255" class="input_ns"></td>
  </tr>
   <tr class="smallfontblack">
    <td width="17%">Other Link URL<sup><font color=red>*</font></sup></td>
    <td width="83%"><input type="text" name="olinkurl" size="30" maxlength=255 class="input_ns"></td>
  </tr>

  <tr>
    <td width="17%"><input type="submit" value="Save" name="submit" class="input_ns">
      <p></td>
    <td width="83%"></td>
  </tr>
  <tr>
    <td width="17%"></td>
    <td width="83%"></td>
  </tr>
  <tr>
    <td width="17%"></td>
    <td width="83%">&nbsp;</td>
  </tr>
</table>
<p>&nbsp;&nbsp;&nbsp; </p>
</form>
</body>

</html>
insert.php
Code:
<?

	// opening connection and seting for errors
	include "../lib/lib.php";
	//error_reporting(5);
	$ctname=getPost("nhead");	
	$count=getPost("nmsg");
	$slink=getPost("score");
	$livematch=getPost("lmatch");
	$slink=getPost("score");	
	$rlink=getPost("rlink");
	$olinktit=getPost("olinktit");
	$olinkurl=getPost("olinkurl");	
	$strQuery="insert into news(nheading,ndetail,ndate,scorebord,livematch,ratting,olinktitle,olinkurl)
	 values('$ctname','$count',sysdate(),'$slink','$livematch','$rlink',
	 '$olinktit','$olinkurl')";
	Update($strQuery);
	header("Location:view_news.php");
?>
the problem is in description of news, in mysql database i have kept the data type of "nmsg" is "TEXT"
Team Leader
4Nov2006,10:39   #4
pradeep's Avatar
The looks pretty simple, there seems to be no problem at all. TEXT type allows 65535 characters, so that shouldn't be a problem.
Try to debug the SQL query by printing it out, and check for any syntactical errors.
Light Poster
4Nov2006,12:30   #5
zeal's Avatar
you right! but i am still face problem......actually there is no error outcome.

some time if i add heading, and let say i add only one line it do take and save it in database...
Light Poster
4Nov2006,12:35   #6
zeal's Avatar
e.g

in description i am try to add

Player of the Year Award
Ricky Ponting (Australia)

Test Player of the Year Award
Ricky Ponting (Australia)

ODI Player of the Year
Michael Hussey (Australia)


but when i add the same...but add more in it it do not insert

Player of the Year Award
Ricky Ponting (Australia)

Test Player of the Year Award
Ricky Ponting (Australia)

ODI Player of the Year
Michael Hussey (Australia)

Women's Player of the Year
Karen Rolton (Australia)


i noted that when i remove the (single quote) after the women's i do insert...

what is this problem i dont think this might be an error..
Go4Expert Founder
6Nov2006,10:31   #7
shabbir's Avatar
' holds a special meaning in the SQL of end of string and so is the problem.
Light Poster
6Nov2006,11:57   #8
zeal's Avatar
oky fine but this problem didnt occur before two month ago...it used to word accurately


any how thanks for your help...
Go4Expert Founder
6Nov2006,12:44   #9
shabbir's Avatar
Probably becauase either you did not had ' in the data you were inserting or had the delimiter backslash for it.
Light Poster
6Nov2006,13:09   #10
zeal's Avatar
well i need to know that solution of this problem...




correction in last post

oky fine but this problem didnt occur before two month ago...it used to work accurately