Current location: Hot Scripts Forums » Programming Languages » PHP » Problem updating a MySQL table using PHP


Problem updating a MySQL table using PHP

Reply
  #1 (permalink)  
Old 03-15-10, 09:50 PM
ghull999 ghull999 is offline
New Member
 
Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Problem updating a MySQL table using PHP

Recently, I switched from MySQL 5.0 to 5.1.30 and have encountered problems when I try to update a form. For some reason, using MySQL 5.1.30, only a limited amount of data will update where as before, I could basically put a huge amount of data in the form and it would save all the data. If there is too much data put into the form, after pressing the submit button, the form will revert to the same old data and never update. I searched the internet and thought maybe it was because there is now an information_schema table listed also under phpMyadmin. I have listed the php page that is giving me the issue below.

PHP Code:

<?

if($act=='chset')
{
mysql_query("UPDATE design SET value='$homepage' WHERE name='homepage'");
mysql_query("UPDATE design SET value='$faq' WHERE name='faq'");
mysql_query("UPDATE design SET value='$terms' WHERE name='terms'");
mysql_query("UPDATE design SET value='$homeright' WHERE name='homeright'");
mysql_query("UPDATE design SET value='$pagebg' WHERE name='pagebg'");
mysql_query("UPDATE design SET value='$h2_style' WHERE name='h2_style'");
mysql_query("UPDATE design SET value='$body_style' WHERE name='body_style'");
mysql_query("UPDATE design SET value='$gmpage' WHERE name='gmpage'");
}
?>
 <?    $c_result mysql_query("select name, comments, value from design where name='homepage'");
$c_row mysql_fetch_row($c_result);
?>
<form name="form1" method="post" action="">
  <table width="100%" border="0">
    <tr> 
      <td colspan="2" bgcolor="#193394"><b><font color="#ffc211" face="Arial, Helvetica, sans-serif" size="2">DESIGN 
        AND CONTENT SETTINGS</font></b></td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <hr noshade size="1">
      </td>
    </tr>
    <tr valign="top"> 
      <td width="28%" align="right"> 
        <?echo $c_row[1]?>
      </td>
      <td width="72%"> 
        <?echo "<textarea name=homepage cols=60 rows=8>$c_row[2]</textarea>"?>
      </td>
    </tr>
    <tr valign="top"> 
      <td colspan="2" align="right"> 
        <hr noshade size="1">
      </td>
    </tr>
    <tr valign="top"> 
      <?    $c_result mysql_query("select name, comments, value from design where name='faq'");
$c_row mysql_fetch_row($c_result);
?>
      <td width="28%" align="right"> 
        <?echo $c_row[1]?>
      </td>
      <td width="72%"> 
        <?echo "<textarea name=faq cols=50 rows=8>$c_row[2]</textarea>"?>
      </td>
    </tr>
    <tr valign="top"> 
      <td colspan="2" align="right"> 
        <hr noshade size="1">
      </td>
    </tr>
    <tr valign="top"> 
      <?    $c_result mysql_query("select name, comments, value from design where name='terms'");
$c_row mysql_fetch_row($c_result);
?>
      <td width="28%" align="right"> 
        <?echo $c_row[1]?>
      </td>
      <td width="72%"> 
        <?echo "<textarea name=terms cols=50 rows=8>$c_row[2]</textarea>"?>
      </td>
    </tr>
    <tr valign="top"> 
      <td colspan="2" align="right"> 
        <hr noshade size="1">
      </td>
    </tr>
    <tr valign="top">       <?    $c_result mysql_query("select name, comments, value from design where name='gmpage'");
$c_row mysql_fetch_row($c_result);
?>
      <td width="28%" align="right">
        <?echo $c_row[1]?>
      </td>
      <td width="72%">
        <?echo "<textarea name=gmpage cols=50 rows=8>$c_row[2]</textarea>"?>
      </td>
    </tr>
    <tr valign="top"> 
      <td colspan="2" align="right">
        <hr noshade size="1">
      </td>
    </tr>
    <tr valign="top"> 
      <?    $c_result mysql_query("select name, comments, value from design where name='homeright'");
$c_row mysql_fetch_row($c_result);
?>
      <td width="28%" align="right"> 
        <?echo $c_row[1]?>
      </td>
      <td width="72%"> 
        <?echo "<textarea name=homeright cols=50 rows=8>$c_row[2]</textarea>"?>
      </td>
    </tr>
    <tr valign="top"> 
      <td colspan="2" align="right"> 
        <hr noshade size="1">
      </td>
    </tr>
    <tr valign="top"> 
      <?    $c_result mysql_query("select name, comments, value from design where name='pagebg'");
$c_row mysql_fetch_row($c_result);
?>
      <td width="28%" align="right"> 
        <?echo $c_row[1]?>
      </td>
      <td width="72%"> 
        <?echo "<input type=text name=pagebg value='$c_row[2]'"?>
      </td>
    </tr>
    <tr valign="top"> 
      <td colspan="2" align="right"> 
        <hr noshade size="1">
      </td>
    </tr>
    <tr valign="top"> 
      <?    $c_result mysql_query("select name, comments, value from design where name='h2_style'");
$c_row mysql_fetch_row($c_result);
?>
      <td width="28%" align="right"> 
        <?echo $c_row[1]?>
      </td>
      <td width="72%"> 
        <?echo "<textarea name=h2_style cols=50 rows=5>$c_row[2]</textarea>"?>
      </td>
    </tr>
    <tr valign="top"> 
      <?    $c_result mysql_query("select name, comments, value from design where name='body_style'");
$c_row mysql_fetch_row($c_result);
?>
      <td colspan="2" align="right"> 
        <hr noshade size="1">
      </td>
    </tr>
    <tr valign="top"> 
      <td width="28%" align="right"> 
        <?echo $c_row[1]?>
      </td>
      <td width="72%"> 
        <?echo "<textarea name=body_style cols=50 rows=5>$c_row[2]</textarea>"?>
      </td>
    </tr>
    <tr valign="top"> 
      <td width="28%" align="right">&nbsp;</td>
      <td width="72%">&nbsp;</td>
    </tr>
    <tr valign="top"> 
      <td width="28%" align="right">&nbsp;</td>
      <td width="72%">&nbsp;</td>
    </tr>
    <tr valign="top"> 
      <td width="28%" align="right">&nbsp;</td>
      <td width="72%">&nbsp;</td>
    </tr>
    <tr valign="top"> 
      <td width="28%" align="right">&nbsp;</td>
      <td width="72%">&nbsp;</td>
    </tr>
    <tr valign="top"> 
      <td width="28%" align="right"> 
        <input type="hidden" name="tp" value="setdesign">
        <input type="hidden" name="act" value="chset">
      </td>
      <td width="72%">&nbsp;</td>
    </tr>
    <tr valign="top"> 
      <td colspan="2" align="right"> 
        <div align="center"> 
          <input type="submit" name="Submit" value="Change settings">
        </div>
      </td>
    </tr>
  </table>
</form>

Last edited by wirehopper; 03-16-10 at 07:07 AM. Reason: PHP tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-16-10, 12:56 PM
bungeebones bungeebones is offline
New Member
 
Join Date: Mar 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
If the script does load some data, but then quits, I would suspect something like an unescaped apostrophe in the data. That would halt the process at that spot.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-16-10, 02:41 PM
dberebi dberebi is offline
Newbie Coder
 
Join Date: Oct 2007
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
do you receive any mysql error? if not try to run the mysql query manually exactly like php so you could know if the problem is with php or mysql
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-16-10, 07:05 PM
ghull999 ghull999 is offline
New Member
 
Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
unescaped apostrophe

Thanks for the replies. It seems to be the unescaped apostrophe issue. When I remove the apostrophe or use the escape slash in front of it, I can add as much data as I want. Is there a way to automatically add the escape slash in front of any apostrophe's in text that is enterred into a form? My script uses html in the forms and the apostrophe's are everywhere. I appreciate any help you can provide.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-16-10, 07:34 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retriving form data from table using php and mysql haritha Script Requests 1 06-09-09 08:30 AM
[SOLVED] PHP &amp; mySQL populating HTML table 88mph PHP 21 04-24-08 04:20 PM
Php Mysql Update and Delete Form Problem mlmorg PHP 1 07-25-07 07:00 PM
Php problem, Mysql fetch arrays (or something) xxvatarxx PHP 3 07-27-05 11:51 AM
Database table contents to email problem (PHP and MySQL) blokeofftheinternet PHP 2 04-29-04 10:34 AM


All times are GMT -5. The time now is 12:34 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.