data is not being update

Discussion in 'MySQL' started by zeal, Nov 3, 2006.

  1. zeal

    zeal New Member

    Joined:
    Nov 3, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    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..
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    Please post the source code, so that I can look for the bug.
     
  3. zeal

    zeal New Member

    Joined:
    Nov 3, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    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"
     
  4. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    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.
     
  5. zeal

    zeal New Member

    Joined:
    Nov 3, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    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...
     
  6. zeal

    zeal New Member

    Joined:
    Nov 3, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    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..
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    ' holds a special meaning in the SQL of end of string and so is the problem.
     
  8. zeal

    zeal New Member

    Joined:
    Nov 3, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    oky fine but this problem didnt occur before two month ago...it used to word accurately


    any how thanks for your help...
     
  9. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Probably becauase either you did not had ' in the data you were inserting or had the delimiter backslash for it.
     
  10. zeal

    zeal New Member

    Joined:
    Nov 3, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  11. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Provide a replacement string where you find ' replace it with \'
     
  12. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    You can also use the addslashes() function in PHP.
     
  13. zeal

    zeal New Member

    Joined:
    Nov 3, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    thanks each person who helped me in this...........
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice