Announcement

Collapse
No announcement yet.

PHP problem - database not updating?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP problem - database not updating?

    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

    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">&nbsp;</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>';

                }

            }

            
    ?>
    Any help would be much appreciated.


    Sean

  • #2
    Are you getting errors or what?

    Please don't PM or VM me for support - I only help out in the threads.
    vBulletin Manual & vBulletin 4.0 Code Documentation (API)
    Want help modifying your vbulletin forum? Head on over to vbulletin.org
    If I post CSS and you don't know where it goes, throw it into the additional.css template.

    W3Schools &lt;- awesome site for html/css help

    Comment


    • #3
      nope, it runs as if its working normally but nothing gets added to the database

      Comment


      • #4
        So it takes the path to add to the database and tells you that it has added stuff to the database ("Your release has been added..."), but it hasn't? Why not echo the query being made at that point?

        Please don't PM or VM me for support - I only help out in the threads.
        vBulletin Manual & vBulletin 4.0 Code Documentation (API)
        Want help modifying your vbulletin forum? Head on over to vbulletin.org
        If I post CSS and you don't know where it goes, throw it into the additional.css template.

        W3Schools &lt;- awesome site for html/css help

        Comment


        • #5
          In your SQL query, you state for it to insert into "$release_sched_db"

          Where is this located, and is it correct?

          Comment


          • #6
            Originally posted by SNN View Post
            In your SQL query, you state for it to insert into "$release_sched_db"

            Where is this located, and is it correct?
            it is defined in the config.php file and is correct

            Comment


            • #7
              right i've done this and am getting:

              INSERT INTO release_sched(act, title, type, release_date, taken_from) VALUES('', 'test', '', '', '')

              Comment


              • #8
                Where are these getting their values from?'$act1', '$title', '$type', '$release_date', '$taken_from'

                I seen a couple of varibles, ($content, $contact) that do not appear to be used. $title is the only varible I noticed that is given a value and it is why the word 'test' appeared in your above post.

                Comment


                • #9
                  Oh yrah sorry they're pulled from a form that's just before this code. I just noticed I hadn't copied the complete script. It worked fine on my previous server, I'm wondering if I need to update the syntax for a newer version of mysql


                  I'm on my phone so can't post the missing part of the script.... Will post it as soon as I get on my laptop

                  Comment


                  • #10
                    HTML Code:
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <html xmlns="http://www.w3.org/1999/xhtml">
                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                    <title>Urapopstar | The Original &amp; The Best</title>
                    <link href="global.css" media="screen" type="text/css" rel="stylesheet" />
                    <link rel="stylesheet" type="text/css" href="dropdown.css" />
                    <script type="text/javascript" src="js/jquery-1.2.2.pack.js"></script>
                    <script type="text/javascript" src="js/ddaccordion.js"></script>
                    <script type="text/javascript" src="js/global.js"></script>
                    </head>
                    
                    <body>
                    <div id="wrapper">
                    	<?php include_once('side_nologin.php'); ?>
                    	
                    	<div id="main">
                    		<div id="content-panel">
                    			<h2>Submit A Release</h2>
                    			<div class="wide">
                    		<?php
                    			//$act = $_POST['actname'];
                    			//form not yet submitted
                    			//display add news form
                    			if (!$_POST['submit'])
                    			{
                    			?>	
                    		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
                    		<table width="400" border="0" cellspacing="0" cellpadding="3">
                    		  <tr>
                    			<td align="right" nowrap="nowrap"><strong>Act Name:</strong></td>
                    			<td>
                    			<?php echo $_POST['actname']; ?><input name="act1" id="act1" type="hidden" value="<?php echo $_POST['actname']; ?>" size="50" maxlength="250" />
                    			</td>
                    		  </tr>
                    		  <tr>
                    			<td align="right" nowrap="nowrap"><strong>Release Title:</strong></td>
                    			<td><input size="50" maxlength="250" type="text" name="title" id="title" /></td>
                    		  </tr>
                    		  <tr>
                    			<td align="right" nowrap="nowrap"><strong>Release Type:</strong></td>
                    			<td>
                    			<select name="type" id="type"><br />
                    				<option value="" selected>Select From List</option>
                    				<option value="1">Single</option>
                    				<option value="2">Album</option>
                    			</select>	
                    			</td>
                    		  </tr>
                    		  <tr>
                    			<td align="right" nowrap="nowrap"><strong>Release Date:</strong></td>
                    			<td>
                    		<?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\" id=\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" id="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">&nbsp;</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	
                    				$query1 = "INSERT INTO $release_sched_db(act, title, type, release_date, taken_from) VALUES('$act1', '$title', '$type', '$release_date', '$taken_from')";
                    				
                    				$result = mysql_query($query1)
                    				or die ("Error in query: $query1. " . mysql_error());
                    				
                    				//print result
                    				echo '<font size="-1">Your release has been added... <a href="releases.php">Go to the release schedule...</a>.</font><br />';
                    				echo  $query1;
                    				//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>';
                    			}
                    		}
                    		?>			
                    		<br /><br />*If you are submitting a collaboration, please PM Izzy or Jake on the forums, as collaboration releases need to be entered manually by a site admin.
                    			</div>
                    		</div>	
                    <br class="Clear" />	
                    <?php
                    	// Get site config
                    	// include('../includes/config.php');
                    	// include('../includes/functions.php');
                    	
                    	// Open 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
                    	$id = $_GET['id'];
                    	
                    	$query = "SELECT id, name, content FROM $static_db WHERE name = '$id'";
                    	$result = mysql_query($query)
                    	or die ("Error in query: $query. " . mysql_error());
                    					
                    	//if a result is returned
                    	if (mysql_num_rows($result) > 0)
                    		{
                    		//turn it into an object
                    		$row = mysql_fetch_object($result);
                    						
                    		//print form with the values that can be edited
                    		include ('includes/content.php');
                    		}
                    		else
                    		{
                    			$query = "SELECT * FROM homepage";
                    			$result = mysql_query($query)
                    			or die ("Error in query: $query. " . mysql_error());
                    	
                    		//if a result is returned
                    		if (mysql_num_rows($result) > 0)
                    			{
                    			//turn it into an object
                    			$row = mysql_fetch_object($result);
                    	
                    			//print homepage
                    			?>
                    		<!-- Charts -->
                    		<div id="content-panel" class="singles">
                    			<h2>Singles</h2>
                    			<div class="singles-img"><!-- Image --></div>
                    			<?php echo $row->singles; ?>
                    		</div>
                    		<div id="content-panel" class="albums">
                    			<h2>Albums</h2>
                    			<div class="albums-img"><!-- Image --></div>
                    			<?php echo $row->albums; ?>
                    		</div>
                    			<?php
                    			}						
                    		}		
                    ?>		
                    		<!-- Quick Links -->
                    		<div id="content-panel" class="quicklinks">
                    			<h2>Quick Links</h2>
                    			<div id="quick">
                    			<ul>
                    				<li><a href="join.php">Join Urapopstar</a></li>
                    				<li><a href="myuraps_submit.php">Submit A Release</a></li>
                    				<li><a href="singles.php">Singles Chart</a></li>
                    				<li><a href="albums.php">Albums Chart</a></li>
                    				<li><a href="promote/index.php">Promote</a></li>
                    			</ul>
                    			</div>			
                    		</div>
                    		<br class="Clear" />
                    	</div>
                    	<br class="Clear" />
                    	<?php include_once('footer.php'); ?>
                    </div>
                    </body>

                    Comment


                    • #11
                      We'll use $act1 for an example. I can not see where you are giving it a value when the form is submitted, for example, where is:

                      $act1 = $_REQUEST['act1'];

                      You are obviously not getting DB errors, so if I overlooked something and $act1 is getting populated, then what I would do directly before writing the data to the DB is put this for testing:

                      $act1 = 'worked';
                      $title = 'worked too';

                      etc for each variable. Run the script and check your DB to see if the words "worked", "worked too", are there. If they are then you know you the variables are not getting the appropriate data.

                      Comment


                      • #12
                        Originally posted by DoE View Post
                        We'll use $act1 for an example. I can not see where you are giving it a value when the form is submitted, for example, where is:

                        $act1 = $_REQUEST['act1'];

                        You are obviously not getting DB errors, so if I overlooked something and $act1 is getting populated, then what I would do directly before writing the data to the DB is put this for testing:

                        $act1 = 'worked';
                        $title = 'worked too';

                        etc for each variable. Run the script and check your DB to see if the words "worked", "worked too", are there. If they are then you know you the variables are not getting the appropriate data.
                        Sorry I should have just posted the entire page in the first palce.

                        the act is defined on the previous page from a form:

                        HTML Code:
                        <?php
                        
                           chdir('/home/seanrobe/public_html/urapopstar/promote'); 
                        
                           require_once('/home/seanrobe/public_html/urapopstar/promote/global.php'); 
                        
                           $uname = $vbulletin->userinfo['username']; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                        
                        <html xmlns="http://www.w3.org/1999/xhtml">
                        
                        <head>
                        
                        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                        
                        <title>Urapopstar | The Original &amp; The Best</title>
                        
                        <link href="global.css" media="screen" type="text/css" rel="stylesheet" />
                        
                        <link rel="stylesheet" type="text/css" href="dropdown.css" />
                        
                        <script type="text/javascript" src="js/jquery-1.2.2.pack.js"></script>
                        
                        <script type="text/javascript" src="js/ddaccordion.js"></script>
                        
                        <script type="text/javascript" src="js/global.js"></script>
                        
                        </head>
                        
                        
                        
                        <body>
                        
                        <div id="wrapper">
                        
                            <?php include_once('side_nologin.php'); ?>
                        
                            
                        
                            <div id="main">
                        
                                <div id="content-panel">
                        
                                    <h2>Submit A Release</h2>
                        
                                    <div class="wide">
                        
                                <form action="myuraps_submit_release.php" method="post">
                        
                                <?php 
                        
                                   if($uname == 'Unregistered')
                        
                                   {
                        
                                   echo "<span class='title'>ERROR</span><br /><br />You need to be logged in to submit a release.  Go back to the <a href=index.php>main page</a> and log in!";
                        
                                   }
                        
                                   else
                        
                                   {
                        
                                   echo "you are logged in as <strong>$uname</strong> is this the act you wish to submit a release for?<br />
                        
                                   If not log out and log in as the act you are submitting for.<br /><br />
                        
                                   If you do wish to submit for $uname then hit the button to proceed<br /><br />
                        
                                   <input type=\"hidden\" value=\"$uname\" name=\"actname\" /><input type=\"submit\" value=\"Hit me\" /><br /><br />*If you are submitting a collaboration, please PM Izzy or Jake on the forums, as collaboration releases need to be entered manually by a site admin.";
                        
                                   }
                        
                                ?>    
                        
                                </form>    
                        
                                    </div>
                        
                                </div>    
                        
                        <br class="Clear" />    
                        
                        <?php
                        
                            // Get site config
                        
                            include('includes/config.php');
                        
                            
                        
                            // Open 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
                        
                            $id = $_GET['id'];
                        
                            
                        
                            $query = "SELECT id, name, content FROM $static_db WHERE name = '$id'";
                        
                            $result = mysql_query($query)
                        
                            or die ("Error in query: $query. " . mysql_error());
                        
                                            
                        
                            //if a result is returned
                        
                            if (mysql_num_rows($result) > 0)
                        
                                {
                        
                                //turn it into an object
                        
                                $row = mysql_fetch_object($result);
                        
                                                
                        
                                //print form with the values that can be edited
                        
                                include ('includes/content.php');
                        
                                }
                        
                                else
                        
                                {
                        
                                    $query = "SELECT * FROM homepage";
                        
                                    $result = mysql_query($query)
                        
                                    or die ("Error in query: $query. " . mysql_error());
                        
                            
                        
                                //if a result is returned
                        
                                if (mysql_num_rows($result) > 0)
                        
                                    {
                        
                                    //turn it into an object
                        
                                    $row = mysql_fetch_object($result);
                        
                            
                        
                                    //print homepage
                        
                                    ?>
                        
                                <!-- Charts -->
                        
                                <div id="content-panel" class="singles">
                        
                                    <h2>Singles</h2>
                        
                                    <div class="singles-img"><!-- Image --></div>
                        
                                    <?php echo $row->singles; ?>
                        
                                </div>
                        
                                <div id="content-panel" class="albums">
                        
                                    <h2>Albums</h2>
                        
                                    <div class="albums-img"><!-- Image --></div>
                        
                                    <?php echo $row->albums; ?>
                        
                                </div>
                        
                                    <?php
                        
                                    }                        
                        
                                }        
                        
                        ?>        
                        
                                <!-- Quick Links -->
                        
                                <div id="content-panel" class="quicklinks">
                        
                                    <h2>Quick Links</h2>
                        
                                    <div id="quick">
                        
                                    <ul>
                        
                                        <li><a href="join.php">Join Urapopstar</a></li>
                        
                                        <li><a href="myuraps_submit.php">Submit A Release</a></li>
                        
                                        <li><a href="singles.php">Singles Chart</a></li>
                        
                                        <li><a href="albums.php">Albums Chart</a></li>
                        
                                        <li><a href="promote/index.php">Promote</a></li>
                        
                                    </ul>
                        
                                    </div>            
                        
                                </div>
                        
                                <br class="Clear" />
                        
                            </div>
                        
                            <br class="Clear" />
                        
                            <?php include_once('footer.php'); ?>
                        
                        </div>
                        
                        </body>
                        
                        </html>

                        Comment


                        • #13
                          That form leads onto this page

                          HTML Code:
                          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                          
                          <html xmlns="http://www.w3.org/1999/xhtml">
                          
                          <head>
                          
                          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                          
                          <title>Urapopstar | The Original &amp; The Best</title>
                          
                          <link href="global.css" media="screen" type="text/css" rel="stylesheet" />
                          
                          <link rel="stylesheet" type="text/css" href="dropdown.css" />
                          
                          <script type="text/javascript" src="js/jquery-1.2.2.pack.js"></script>
                          
                          <script type="text/javascript" src="js/ddaccordion.js"></script>
                          
                          <script type="text/javascript" src="js/global.js"></script>
                          
                          </head>
                          
                          
                          
                          <body>
                          
                          <div id="wrapper">
                          
                              <?php include_once('side_nologin.php'); ?>
                          
                              
                          
                              <div id="main">
                          
                                  <div id="content-panel">
                          
                                      <h2>Submit A Release</h2>
                          
                                      <div class="wide">
                          
                                  <?php
                          
                                      //$act = $_POST['actname'];
                          
                                      //form not yet submitted
                          
                                      //display add news form
                          
                                      if (!$_POST['submit'])
                          
                                      {
                          
                                      ?>    
                          
                                  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
                          
                                  <table width="400" border="0" cellspacing="0" cellpadding="3">
                          
                                    <tr>
                          
                                      <td align="right" nowrap="nowrap"><strong>Act Name:</strong></td>
                          
                                      <td>
                          
                                      <?php echo $_POST['actname']; ?><input name="act1" id="act1" type="hidden" value="<?php echo $_POST['actname']; ?>" size="50" maxlength="250" />
                          
                                      </td>
                          
                                    </tr>
                          
                                    <tr>
                          
                                      <td align="right" nowrap="nowrap"><strong>Release Title:</strong></td>
                          
                                      <td><input size="50" maxlength="250" type="text" name="title" id="title" /></td>
                          
                                    </tr>
                          
                                    <tr>
                          
                                      <td align="right" nowrap="nowrap"><strong>Release Type:</strong></td>
                          
                                      <td>
                          
                                      <select name="type" id="type"><br />
                          
                                          <option value="" selected>Select From List</option>
                          
                                          <option value="1">Single</option>
                          
                                          <option value="2">Album</option>
                          
                                      </select>    
                          
                                      </td>
                          
                                    </tr>
                          
                                    <tr>
                          
                                      <td align="right" nowrap="nowrap"><strong>Release Date:</strong></td>
                          
                                      <td>
                          
                                  <?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\" id=\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" id="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">&nbsp;</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    
                          
                                          $query1 = "INSERT INTO $release_sched_db(act, title, type, release_date, taken_from) VALUES('$act1', '$title', '$type', '$release_date', '$taken_from')";
                          
                                          
                          
                                          $result = mysql_query($query1)
                          
                                          or die ("Error in query: $query1. " . mysql_error());
                          
                                          
                          
                                          //print result
                          
                                          echo '<font size="-1">Your release has been added... <a href="releases.php">Go to the release schedule...</a>.</font><br />';
                          
                                          echo  $query1;
                          
                                          //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>';
                          
                                      }
                          
                                  }
                          
                                  ?>            
                          
                                  <br /><br />*If you are submitting a collaboration, please PM Izzy or Jake on the forums, as collaboration releases need to be entered manually by a site admin.
                          
                                      </div>
                          
                                  </div>    
                          
                          <br class="Clear" />    
                          
                          <?php
                          
                              // Get site config
                          
                              // include('../includes/config.php');
                          
                              // include('../includes/functions.php');
                          
                              
                          
                              // Open 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
                          
                              $id = $_GET['id'];
                          
                              
                          
                              $query = "SELECT id, name, content FROM $static_db WHERE name = '$id'";
                          
                              $result = mysql_query($query)
                          
                              or die ("Error in query: $query. " . mysql_error());
                          
                                              
                          
                              //if a result is returned
                          
                              if (mysql_num_rows($result) > 0)
                          
                                  {
                          
                                  //turn it into an object
                          
                                  $row = mysql_fetch_object($result);
                          
                                                  
                          
                                  //print form with the values that can be edited
                          
                                  include ('includes/content.php');
                          
                                  }
                          
                                  else
                          
                                  {
                          
                                      $query = "SELECT * FROM homepage";
                          
                                      $result = mysql_query($query)
                          
                                      or die ("Error in query: $query. " . mysql_error());
                          
                              
                          
                                  //if a result is returned
                          
                                  if (mysql_num_rows($result) > 0)
                          
                                      {
                          
                                      //turn it into an object
                          
                                      $row = mysql_fetch_object($result);
                          
                              
                          
                                      //print homepage
                          
                                      ?>
                          
                                  <!-- Charts -->
                          
                                  <div id="content-panel" class="singles">
                          
                                      <h2>Singles</h2>
                          
                                      <div class="singles-img"><!-- Image --></div>
                          
                                      <?php echo $row->singles; ?>
                          
                                  </div>
                          
                                  <div id="content-panel" class="albums">
                          
                                      <h2>Albums</h2>
                          
                                      <div class="albums-img"><!-- Image --></div>
                          
                                      <?php echo $row->albums; ?>
                          
                                  </div>
                          
                                      <?php
                          
                                      }                        
                          
                                  }        
                          
                          ?>        
                          
                                  <!-- Quick Links -->
                          
                                  <div id="content-panel" class="quicklinks">
                          
                                      <h2>Quick Links</h2>
                          
                                      <div id="quick">
                          
                                      <ul>
                          
                                          <li><a href="join.php">Join Urapopstar</a></li>
                          
                                          <li><a href="myuraps_submit.php">Submit A Release</a></li>
                          
                                          <li><a href="singles.php">Singles Chart</a></li>
                          
                                          <li><a href="albums.php">Albums Chart</a></li>
                          
                                          <li><a href="promote/index.php">Promote</a></li>
                          
                                      </ul>
                          
                                      </div>            
                          
                                  </div>
                          
                                  <br class="Clear" />
                          
                              </div>
                          
                              <br class="Clear" />
                          
                              <?php include_once('footer.php'); ?>
                          
                          </div>
                          
                          </body>
                          
                          </html>

                          Comment


                          • #14
                            Sorry, I been pretty busy, and have actually forgotten to check this forum for a few days.

                            If I understand you right, the above code worked as intended on your old server, and on the new server it doesn't write the values into the DB? And you never modified it in any way?

                            If so, your server may handle submmited form data differently. Try to use $_request, instead of $_post for reading in the data. In your form you have method="post" which is fine for submitting the form. But to read the data being submitted I use $_REQUEST['xxx']. E.g.: $username = $_REQUEST['username']. You may want to try that and see what happens.

                            Comment


                            • #15
                              Sorry I've only just come back to you, I've been really busy with work and have only just had a chance to test this, and unfortunately i still only get:

                              INSERT INTO release_sched(act, title, type, release_date, taken_from) VALUES('', 'Sean Testing Server', '', '', '')

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X