Jump to content

Getting and updating data


Mr Chris

Recommended Posts

Hi Guys,

Trying to write a script that will GET unique rows (story_id’s) from a MYSQL database and post them back on the below page where I can UPDATE them, but it just seems to do nothing and I get an error on this line:

Parse error: parse error, unexpected '{', expecting '(' in /home/sleaz/public_html/greenock/news/edit.php on line 14

[b] $result = mysql_query("Update table set section='$section', added_by='$added_by', headline='$headline', byline_name='$byline_name', appeared='$appeared', opening='$opening', body_text='$body_text', picture='$picture', pic_caption='$pic_caption', pic_ref='$pic_ref', notes='$notes' where story_id=".$_GET['story_id']); [/b]

Can someone please explain where I have gone wrong in how I achieve the above?

Thanks

[code]
<?php

// Set the variables for access;
include("**************");

// Update Query
if
{
        $result = mysql_query("Update cms_stories set section='$section', added_by='$added_by', headline='$headline', byline_name='$byline_name', appeared='$appeared', opening='$opening', body_text='$body_text', picture='$picture', pic_caption='$pic_caption', pic_ref='$pic_ref', notes='$notes' where story_id=".$_GET['story_id']);
        $msg = "The Story record has been updated in the database - Please Click <a href=\"menu.php\">Here</a> to return to the main menu";
}

// Get Story ID From Database
if(isset($_GET['story_id']))
{
$result = mysql_db_query("Select * From table where story_id=".$_GET['story_id'],$Link);
$row = mysql_fetch_array($result, MYSQL_BOTH);
$section = $row['section'];
$added_by = $row['added_by'];
$headline = $row['headline'];
$byline_name = $row['byline_name'];
$appeared = $row['appeared'];
$opening = $row['opening'];
$body_text = $row['body_text'];
$picture = $row['picture'];
$pic_caption = $row['pic_caption'];
$pic_ref = $row['pic_ref'];
$notes = $row['notes'];
}

}
// Run Query
  $link = mysql_connect;
  mysql_select_db($db);
  $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  mysql_close();
}

?>
<html>
<head>
<title>Website Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
                BODY,H1,H2,H3,H4,H5,UL,LI,INPUT,A,B,TEXTAREA { font-family: Geneva, Helvetica, Arial, sans-serif }
                P { font-family: Geneva, Helvetica, Arial, sans-serif; }
                A { color: #1c1c1c }
                A:visited { color: #1c1c1c }
                A:hover { text-decoration: none; color: #ffffff; background-color: #3333cc }
        </style>
</head>

<body bgcolor="#CCCCCC">
<table width="95%" border="0" align="center" bgcolor="#FFFFFF">
  <tr>
    <td> </td>
  </tr>
  <tr bgcolor="#CC0000">
    <td height="24">
      <div align="center"><b><font color="#FFFFFF">ADD A STORY</font></b></div>
    </td>
  </tr>
  <tr>
    <td>
      <table width="70%" border="0" align="center">
        <tr>
          <td><?php echo $msg?></td>
        </tr>
      </table>
      <br>
        <form action="" method="post" enctype="multipart/form-data" name="uploadform">
      <table width="70%" border="0" align="center" bgcolor="#000000">
        <tr>
          <td height="442">
            <table width="100%" border="0" bgcolor="#FFFFFF" cellpadding="3" cellspacing="1">
              <tr>
                <td width="26%" bgcolor="#CCCCCC" height="24"><b>Edition:</b></td>
                  <td width="74%" height="24"><b><font color="#CC0000">Website.</font></b></td>
              </tr>
              <tr>
                <td width="26%" bgcolor="#CCCCCC"><b>Section:</b></td>
                <td width="74%">
                  <select name="section">
                    <option><?php echo $section?></option>
                    <option value="news">News</option>
                    <option value="sport">Sport</option>
                    <option value="business">Business</option>
                    <option value="viator">Viator</option>
                  </select>
                </td>
              </tr>
              <tr>
                <td width="26%" bgcolor="#CCCCCC"><b>Added by:</b></td>
                  <td width="74%">
                    <input name="added_by" type="text" id="added_by" value="<?php echo $added_by?>" size="50">
                  </td>
              </tr>
              <tr>
                <td width="26%" bgcolor="#CCCCCC"><b>Headline:</b></td>
                <td width="74%">
                    <input name="headline" type="text" id="headline" value="<?php echo $headline?>" size="50">
                  </td>
              </tr>
              <tr>
                <td width="26%" bgcolor="#CCCCCC"><b>Byline Name:</b></td>
                  <td width="74%">
                    <input name="byline_name" type="text" id="byline_name" value="<?php echo $byline_name?>" size="35" maxlength="128">
                  </td>
              </tr>
              <tr>
                <td width="26%" bgcolor="#CCCCCC">
                  <p><b>Appeared in G Telegraph:</b></p>
                </td>
                <td width="74%">
                 <input name="appeared" type="text" id="appeared" value="<?php echo $appeared?>" size="30">
                </td>
              </tr>
              <tr bgcolor="#CC0000">
                <td colspan="2">
                  <div align="center"><b><font color="#FFFFFF">OPENING PARAGRAPH</font></b></div>
                </td>
              </tr>
              <tr>
                <td colspan="2">
                  <div align="center">
                      <textarea name="opening" id="opening" cols="80" rows="7"><?php echo $opening?></textarea>
                  </div>
                </td>
              </tr>
              <tr bgcolor="#CC0000">
                <td colspan="2">
                  <div align="center"><b><font color="#FFFFFF">BODY TEXT</font></b></div>
                </td>
              </tr>
              <tr>
                <td colspan="2">
                    <div align="center">
                      <textarea name="body_text" id="body_text" cols="80" rows="25"><?php echo $body_text?></textarea>
                    </div>
                </td>
              </tr>
              <tr bgcolor="#CC0000">
                <td colspan="2">
                  <div align="center"><b><font color="#FFFFFF">PICTURE (IF REQUIRED)</font></b></div>
                </td>
              </tr>
              <tr>
                <td width="26%" bgcolor="#CCCCCC"><b>Pic to Upload:</b></td>
                  <td width="74%">  </td>
              </tr>
              <tr>
                <td width="26%" bgcolor="#CCCCCC" valign="top"><b>Caption:</b></td>
                <td width="74%">
                    <textarea name="pic_caption" id="pic_caption" cols="40"><?php echo $pic_caption?></textarea>
                </td>
              </tr>
              <tr>
                <td width="26%" bgcolor="#CCCCCC"><b>Pic Ref No:</b></td>
                <td width="74%">
                    <input name="pic_ref" type="text" id="pic_ref" value="<?php echo $pic_ref?>" size="30">
                    <br>
                </td>
              </tr>
              <tr bgcolor="#CC0000">
                <td colspan="2">
                  <div align="center"><b><font color="#FFFFFF">ADDITIONAL NOTES
                    (NOT PUBLISHED)</font></b></div>
                </td>
              </tr>
              <tr>
                <td width="26%" bgcolor="#CCCCCC" valign="top"><b>Notes:</b></td>
                <td width="74%">
                  <textarea name="notes" id="notes" rows="4" cols="65"><?php echo $notes?></textarea>
                  </td>
              </tr>
              <tr>
                <td width="26%"> </td>
                <td width="74%">
                  <input name="upload" type="submit" class="box" id="upload" value="  Upload  ">
                  <input type="reset" name="Reset" value="Clear Story">
                  </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      </form>
    </td>
  </tr>
</table>
</body>
</html>
[/code]
Link to comment
Share on other sites

Whoops:

First IF should be:

[code]if(!isset($_GET['story_id'])
{
        $result = mysql_query("Update news set section='$section', added_by='$added_by', headline='$headline', byline_name='$byline_name', appeared='$appeared', opening='$opening', body_text='$body_text', picture='$picture', pic_caption='$pic_caption', pic_ref='$pic_ref', notes='$notes' where story_id=".$_GET['story_id']);
        $msg = "The Story record has been updated in the database - Please Click <a href=\"menu.php\">Here</a> to return to the main menu";
}[/code]

But still the same error - any further ideas please?
Link to comment
Share on other sites

[b]
Plz try this by removing the single quote in the get
where story_id=".$_GET[story_id]);
and you hv put an extra "}" in line number 31 plz check taht also

and try to connect mysql before sending any sql queries
[/b]
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.