473,216 Members | 1,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

Problem Loading Two db Tables with Script

The purpose of the script below is to load the same news item into two
different MySQL tables (thus displaying the same news item on two web
pages). The problem I am having is this: The script actually
works--but just once. The next time I run it (even days later), it
will not load the data. It just displays the error message from line
#37; in other words, there is no value in $result.

(BTW, I have stripped out all security temporarily. I understand that
in its present form this is an insecure script. It is not being left
on the server.)

Server PHP: 4.3.4
Server MySQL: 3.23.58

Can anyone figure out why this script would successfully load the two
tables, but only once? Thank you for your time and consideration.

dsl

------------------------------

<html>
<?php
$strTitle = 'Post Weekly News';
require ("header.php");
?>
<body>
<div id="center">
<FORM action="<?=$PHP_SELF?>" method="POST">
<p>Headline: <br>
<INPUT TYPE="text" NAME="headline" SIZE="50" /><br>
<p>Story text: <br>
<TEXTAREA NAME="story" ROWS="10" COLS="50" /></TEXTAREA><br>
<p>Start Date: <br>
<INPUT TYPE="text" NAME="initdate" SIZE="12" /><br>
<p>End Date: <br>
<INPUT TYPE="text" NAME="expdate" SIZE="12" /></p>
<INPUT TYPE=submit name="reg2" VALUE="Submit" />
<INPUT TYPE=reset VALUE="Clear Fields" />
</FORM>
<?php
// Connect to the database server
$dbcnx = @mysql_connect("localhost", <user>, <password>);
if (!$dbcnx) exit();
// Select the database
if (! @mysql_select_db("<db_name>")) exit();
if (!isset($reg2)) {
echo("No submission yet.");
}else{
// load row into news table
$sql = "insert into news set
headline='$headline',
story='$story',
initdate='$initdate',
expdate='$expdate'";
$result = (@mysql_query($sql));
if (!$result) {
echo("<p>ERROR: <b>News</b> table NOT loaded.</p>");
}else{
echo("<p><b>News</b> table loaded.</p>");
}
if ($result) {
$sql2 = "insert into hc_news set
headline='$headline',
story='$story',
initdate='$initdate',
expdate='$expdate'";
$result2 = (@mysql_query($sql2));
if (!$result2) {
echo("<p>ERROR: <b>HC_News</b> table NOT
loaded.</p>");
}else{
echo("<p><b>HC_News</b> table loaded.</p>");
echo("<p>Both tables loaded successfully.</p>");
}
}
}
?>
</div>
</body>
</html>

Jul 17 '05 #1
0 1478

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Cenk Genisol | last post by:
Hi NG, I am relatively new to Web developement and have some questions to you. I've got a Masterpage where some graphics are embedded by CSS. They format the borders of tables, which store...
2
by: nick.taylor | last post by:
Hi, I've been trying for weeks to figure out this problem. I'm developing a simple Javascript app that loads an XML file from a server, parses the contents, and displays them. But I am...
13
by: Jon Paal | last post by:
this works as shown: <script Language="javascript" src="http://127.0.0.1/syndicate.ashx?d=suppliers"></script> is there a way to set src programmatically ??
5
by: toffee | last post by:
Hi all, I've seen a really cool effect which i would like to use on an intranet site. Am referring to the 'LOADING..' animation you see when switching pages. I've seen it somewhere on a website...
2
by: billkirim | last post by:
i am using this code to preload my site: <script type="text/javascript"> document.write('<div id="loading"><br><br>The musicase is Loading...</div>'); window.onload=function(){ ...
1
by: mlikesit | last post by:
I am trying to get the following code to pre-load some images before re-dirrecting the user. The problem is that the onError event gets called for all of the images immediately. I've tripple...
0
VietPP
by: VietPP | last post by:
Hi all, I've asked too much question in this day, hehe. I'm trying to export my table data in OracleDB to excel. The problem is my charset in database is US7ACSII (using Vietnamese font), when...
11
by: Flexor | last post by:
I have a php script that runs from command line and makes an https request to paypal, using curl. It works fine if I run it from a web page. It fails if I run it from CLI. The error I get from...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.