Jump to content

Update to SQL


tgcampbell

Recommended Posts

Hello,

I use HTMLAREA to view and update webpage content from an SQL Database but the update part is not working. Does anyone know why? Thanks in advance.

Code:
[code]
<form name="St Martins GAA" method="post" action="">
<table width="513" border="1" cellpadding="2" cellspacing="0" bordercolor="#5493B4">
<tr>
<td bgcolor="#5493B4" width="875">
<table width="696" cellpadding="2" cellspacing="0">
<tr>
<td bgcolor="#5493B4" width="692"> <table width="500" border="0" cellspacing="0" cellpadding="2">
<tr bgcolor="ACA899">
</tr>
<tr>
<input name="onderwerp" type="text" id="onderwerp" value="Our Club" size="20">
</td>
</tr>
</table></td>
</tr>
</table>
<div align="left"></div>
<div align="left">
<span style="background-color: #5493B4">
<textarea name="Club" style="width:100%; height:500" rows="1" cols="20">
<?
//alle aanwezige info in de SQL db wordt hieronder weergegeven;
//in elke rij is een veld edit beschikbaar. Dit is een link naar edit.php met GET variabelen;
$db = @mysql_pconnect("localhost", "stmartins", "")
or die ("De verbinding met de SQL server is mislukt");
@mysql_select_db("gaa", $db)
or die ("verbinding db mislukt");
$query = "SELECT * FROM content WHERE Id = '1'"; //Page number;
$result = mysql_query($query, $db);
if($result) {
while ($id_row = mysql_fetch_array($result)) {

echo "<tr>
<td bgcolor='FFFFFF'><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><div align='center'>", $id_row['Content'],"</div></font></td></tr>";
}
}
else {
echo "Data not found";
}
?>
</textarea></span>
<br>
<input type="submit" name="Submit" value="Update">
<br>
<script language="javascript1.2">
var config = new Object(); // create new config object

config.width = "90%";
config.height = "200px";
config.bodyStyle = 'background-color: white; font-family: "Verdana"; font-size: x-small;';
config.debug = 0;

// NOTE: You can remove any of these blocks and use the default config!

config.toolbar = [
['fontname'],
['fontsize'],
['fontstyle'],
['linebreak'],
['bold','italic','underline','separator'],
// ['strikethrough','subscript','superscript','separator'],
['justifyleft','justifycenter','justifyright','separator'],
['OrderedList','UnOrderedList','Outdent','Indent','separator'],
['forecolor','backcolor','separator'],
['HorizontalRule','Createlink','InsertImage','htmlmode','separator'],
['about','help','popupeditor'],
];

config.fontnames = {
"Arial": "arial, helvetica, sans-serif",
"Courier New": "courier new, courier, mono",
"Georgia": "Georgia, Times New Roman, Times, Serif",
"Tahoma": "Tahoma, Arial, Helvetica, sans-serif",
"Times New Roman": "times new roman, times, serif",
"Verdana": "Verdana, Arial, Helvetica, sans-serif",
"impact": "impact",
"WingDings": "WingDings"
};
config.fontsizes = {
"1 (8 pt)": "1",
"2 (10 pt)": "2",
"3 (12 pt)": "3",
"4 (14 pt)": "4",
"5 (18 pt)": "5",
"6 (24 pt)": "6",
"7 (36 pt)": "7"
};

//config.stylesheet = "http://www.domain.com/sample.css";

config.fontstyles = [ // make sure classNames are defined in the page the content is being display as well in or they won't work!
{ name: "headline", className: "headline", classStyle: "font-family: arial black, arial; font-size: 28px; letter-spacing: -2px;" },
{ name: "arial red", className: "headline2", classStyle: "font-family: arial black, arial; font-size: 12px; letter-spacing: -2px; color:red" },
{ name: "verdana blue", className: "headline4", classStyle: "font-family: verdana; font-size: 18px; letter-spacing: -2px; color:blue" }

// leave classStyle blank if it's defined in config.stylesheet (above), like this:
// { name: "verdana blue", className: "headline4", classStyle: "" }
];

editor_generate('Club',config);
</script>
<br>
</div> </td>
</tr>
</table>
</form>



\\ Update Section



<?
If ($Submit) {
// invoervelden uit cms_edit.php ophalen;
$id_row = $_POST['Club'];


// verbinding maken met de db;
$db = @mysql_pconnect("localhost", "stmartins", "")
or die ("De verbinding met de SQL server is mislukt");
@mysql_select_db("gaa", $db)
or die ("verbinding db mislukt");

// nu de invoervelden in de SQL DB updaten;
$query = "UPDATE content SET Content = '$id_row'";
mysql_query($query) or die ("query mislukt");
echo "<script language = 'javascript'>alert('The update is complete');</script>";
echo "<script language = 'javascript'>window.location='index.php';</script>";
}
?>[/code]

[b]EDIT BY OBER: PLEASE USE CODE TAGS![/b]
Link to comment
Share on other sites

Hi,

Yes, just the 1 text area (name=club) to update to the content table into the Content section :

Code:
<?
If ($Submit) {

$id_row = $_POST['Club'];

// verbinding maken met de db;
$db = @mysql_pconnect("localhost", "stmartins", "paddy")
or die ("De verbinding met de SQL server is mislukt");
@mysql_select_db("gaa", $db)
or die ("verbinding db mislukt");

$query = "UPDATE content SET Content = '$id_row'";
mysql_query($query) or die ("query mislukt");
echo "<script language = 'javascript'>alert('The update is complete');</script>";
echo "<script language = 'javascript'>window.location='index.php';</script>";
}
?>

But this does not seem to work. Please see the sample link : [a href=\"http://www.stmartinsgaa.nl/htmlarea/Update_club.php\" target=\"_blank\"]http://www.stmartinsgaa.nl/htmlarea/Update_club.php[/a]
As you will see from the link it just seems to refresh and not run the update query.
I have tried everything ( well maybe not everything ) but it just will not run. Please help!

Any help would be greatfull! By the way we are based in The Netherlands -Groningen. A small club just starting to develop. Hard work though. Little support. Hope alls well back home.

Thanks for any forthcomming help.

Tom
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.