Hey,
I recently moved servers and one of my scripts isn't updating the database on the new server when a user submits to it.
It was working fine before but for some reason its not now.
I've checked all the database settings and they work fine, and as far as I can tell the code (albeit basic) is correct, can anyone help?
It runs through the entire script and tells you its been successful, however doesn't update the database
Any help would be much appreciated.
Sean
I recently moved servers and one of my scripts isn't updating the database on the new server when a user submits to it.
It was working fine before but for some reason its not now.
I've checked all the database settings and they work fine, and as far as I can tell the code (albeit basic) is correct, can anyone help?
It runs through the entire script and tells you its been successful, however doesn't update the database
PHP Code:
<?php
include('includes/config.php');
include('includes/functions.php');
chdir('/home/seanrobe/public_html/urapopstar/');
//Open a connection to the database
$db = mysql_connect($hostname, $user, $pass) or die ('Error connecting to mysql');
mysql_select_db($name) or die ('Error connecting to mysql');
//generate and execute the sql query
$query = "SELECT * FROM $release_date_db ORDER BY date ASC";
$result = mysql_query($query)
or die ("Error in query: $query. " . mysql_error());
//echo the drop down menu
echo "<select name=\"release_date\"><br>";
echo "<option value=\"\">Select From List</option>";
//if records are present
if (mysql_num_rows($result) > 0)
{
//iterate through results
//print title and links to edit and delete
while ($row = mysql_fetch_object($result))
{
?>
<option value="<?php echo $row->date; ?>"><?php echo formatDate($row->date); ?></option>
<?php
}
//echo the closing tag for drop down menu
}
echo "</select><br />";
?>
</td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><strong>Taken From:</strong></td>
<td>
<select name="taken_from">
<option value="from current album">Current Album</option>
<option value="from forthcoming album">Forthcoming Album</option>
<option value="one off single">One off Single</option>
</select>
</td>
</tr>
<tr>
<td align="right"> </td>
<td><input type="Submit" name="submit" value="Add Release" /></td>
</tr>
</table>
</form>
<?php
}
else
{
chdir('/home/seanrobe/public_html/urapopstar');
include('includes/config.php');
include('includes/functions.php');
//set up error list
$errorList = array();
//$act = $_POST['$act1'];
$title = $_POST['title'];
$content = $_POST['type'];
$contact = $_POST['release_date'];
//validate text input fields
/*if (trim($_POST['act']) == '')
{
$errorList[] = 'Invalid act';
}*/
if (trim($_POST['title']) == '')
{
$errorList[] = 'Invalid title';
}
if (trim($_POST['type']) == '')
{
$errorList[] = 'Invalid release type';
}
if (trim($_POST['release_date']) == '')
{
$errorList[] = 'You have failed to select a release date.';
}
//check for errors
//if none are found...
if (sizeof($errorList) == 0)
{
//Open a connection to the database
chdir('/home/seanrobe/public_html/urapopstar');
$db = mysql_connect($hostname, $user, $pass) or die ('Error connecting to mysql');
mysql_select_db($name) or die ('Error connecting to mysql');
/**
act
title
type
release_date
taken_from
*/
//generate and execute query
$query = "INSERT INTO $release_sched_db(act, title, type, release_date, taken_from) VALUES('$act1', '$title', '$type', '$release_date', '$taken_from')";
$result = mysql_query($query)
or die ("Error in query: $query. " . mysql_error());
//print result
echo '<font size="-1">Your release has been added... <a href="releases.php">Go to the release schedule...</a>.</font>';
//close the database connection
mysql_close($db);
}
else
{
//errors found
//print a list
echo '<font size="-1">The following errors were found:';
echo '<br />';
echo '<ul>';
for ($x=0; $x<sizeof($errorList); $x++)
{
echo "<li>$errorList[$x]";
}
echo '</ul></font>';
}
}
?>
Sean
Comment