Problems with my site once uploaded online

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dthomas31uk
Forum Newbie
Posts: 19
Joined: Mon Oct 13, 2008 8:14 am

Problems with my site once uploaded online

Post by dthomas31uk »

Hi. Have developed a form that connects with my database using PHP. All of it works great on my localhost, but when I have uploaded it to my server it aint doing the same thing. First off you select the date, thats ok, then you select a country from the drop down list it sees the countries in the database, but when you select it from the drop down list is cannot locate it and comes up with page not found error. Any ideas what I am doing wrong guys.
Here is a link to the page concerned online
http://www.gostoke.eu/eu_home.php

And here is the code. The following is the euhome.php

Code: Select all

<?php
$dbservertype='mysql';
$servername='localhost';
// username and password to log onto db server
$dbusername='**********';
$dbpassword='**********';
// name of database
$dbname='dthomas_europe';
 
////////////////////////////////////////
////// DONOT EDIT BELOW  /////////
///////////////////////////////////////
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
//////// End of connecting to database ////////
?>
 
<!doctype html public "-//w3c//dtd html 3.2//en">
 
<html>
 
<head>
<title>Multiple drop down list box from plus2net</title>
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='dd.php?cat=' + val ;
}
</script>
 
</head>
 
<body>
<form method=post name=f1 action='dd-check.php'>
 
<select name = 'day' class="listBox" tabindex="4" >
    <?php
    // generate day numbers
    for ($x = 1; $x <= 31; $x++) {
        echo "<option value = $x>$x</option>";
    }
    ?>
    </select>
    <select name = 'month' class="listBox" tabindex="4" >
    <?php
    // generate month names
    for ($x = 1; $x <= 12; $x++) {
        echo "<option value=$x>".date('F', mktime(0, 0, 0, $x, 1, 1)).'</option>';
    }
    ?>
    </select>
    <select name = 'year' class="listBox" tabindex="4" >
    <?php
    // generate year values
    for ($x = 2007; $x <= 2008; $x++) {
        echo "<option value=$x>$x</option>";
    }
    ?>
    </select> 
<br />
 
<?
 
/*
If register_global is off in your server then after reloading of the page to get the value of cat from query string we have to take special care.
To read more on register_global visit.
  http://www.plus2net.com/php_tutorial/re ... lobals.php
*/
//@$cat=$_GET['cat']; // Use this line or below line if register_global is off
@$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off
 
///////// Getting the data from Mysql table for Pick Up list box//////////
$querPick=mysql_query("SELECT city, id FROM uk_place");
if (!$querPick) {
exit('<p>Unable to obtain category list from the '  .
       'database.</p>');
} 
///////////// End of query for first list box////////////
 
 
 
///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT country,id FROM eu_place order by country"); 
///////////// End of query for first list box////////////
 
/////// for second drop down list we will check if category is selected else we will display all the subcategory///// 
if(isset($cat) and strlen($cat) > 0){
$quer=mysql_query("SELECT DISTINCT city FROM eu_place where id=$cat order by city"); 
}else{$quer=mysql_query("SELECT DISTINCT city FROM eu_place order by city"); } 
////////// end of query for second subcategory drop down list box ///////////////////////////
 
 
 
 
/// Add your form processing page address to action in above line. Example  action=dd-check.php////
//////////        Starting of first drop downlist /////////
echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
echo mysql_error();
while($noticia2 = mysql_fetch_array($quer2)) { 
if($noticia2['id']==@$cat){echo "<option selected value='$noticia2[id]'>$noticia2[country]</option>"."<BR>";}
else{echo  "<option value='$noticia2[id]'>$noticia2[country]</option>";}
}
echo "</select>"."<BR>";
//////////////////  This will end the first drop down list ///////////
 
 
 
//////////        Starting of second drop downlist /////////
echo "<select name='subcat'><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer)) { 
echo  "<option value='$noticia[city]'>$noticia[city]</option>";
}
echo "</select>"."<BR>";
//////////////////  This will end the second drop down list ///////////
 
 
 
echo 'Load from 14m3 - 20m3' . "<label><input type='radio' name='load' value='luton'</label>"."<BR>";
echo 'Load from 7m3 - 14m3'."<label><input type='radio' name='load' value='full_load'</label>"."<BR>";
echo 'Load from 1m3 - 7m3' . "<label><input type='radio' name='load' value='half_load'</label>"."<BR>";
 
 
//////////        Starting of second drop downlist /////////
echo "<select name='pickup'><option value=''>Select one</option>";
while($pickup = mysql_fetch_array($querPick)) { 
echo  "<option value='$pickup[city]'>$pickup[city]</option>";
}
echo "</select>"."<BR>";
//////////////////  This will end the second drop down list ///////////
 
 
//// Add your other form fields as needed here/////
echo "<input type=submit value=Submit>";
 
?>
 
</form>
 

and this is for the next page that organises the form data 'dd-check.php'

Code: Select all

<?php
include 'http://www.gostoke.eu/eu_home.php';
?>
 
 
 
<!doctype html public "-//w3c//dtd html 3.2//en">
 
<html>
 
<head>
<title>Demo Multiple drop down list box from plus2net</title>
</head>
 
<body>
 
<?php
$pickup=$_POST['pickup'];
$cat=$_POST['cat'];
$subcat=$_POST['subcat'];
$load=$_POST['load'];
$appointment_date = sprintf('%02d-%02d-%04d',$_POST['day'], $_POST['month'], $_POST['year']); //mm-dd-yyyy
echo "Date required $appointment_date"."<BR>";
echo "Picking up from $pickup" ."<BR>";
echo "Going to $subcat"."<BR>";
 
 
 
 
$result = mysql_query("SELECT full_price, half_price, luton FROM eu_place WHERE city = '" . mysql_real_escape_string($subcat) . "'") or die(mysql_error());
$row = mysql_fetch_array($result);
 
switch($load) {
    case 'full_load' :
    $total = $row['full_price'];
    break;
    case 'half_load' :
    $total = $row['half_price'];
    break;
    case 'luton':
    $total = $row['luton'];
    break;
   
} 
 
 
$rResult = mysql_query("SELECT price FROM uk_place WHERE city = '" . mysql_real_escape_string($pickup) . "'") or die(mysql_error());
while ($aRow = mysql_fetch_array($rResult, MYSQL_ASSOC))
{
    $iPrice = $aRow['price'];
    echo "£";
    echo ($iPrice) + ($total)."<BR>";
}
 
echo "<form method=post name=f2 action='confirm.php'>";
echo 'To confirm the above details, please enter your details below and click submit' . "<br />";
echo  'Full Name' . "<input type='text' name='name' id='name'/>" . "<br />"; 
echo  'Telephone Number' . "<input type='text' name='telephone' id='telephone'/>" . "<br />"; 
echo  'Email' . "<input type='text' name='email' id='email'/>" . "<br />";
echo 'Comments:' ."<textarea id='textareainput' name='textareainput' rows='10' cols='22'></textarea>";
echo "<input type='hidden' name='date' id='date' value='$appointment_date'/>";
echo "<input type='hidden' name='pickUpPoint' id='pickUpPoint' value='$pickup'/>";
echo "<input type='hidden' name='destination' id='destination' value='$subcat'/>";
echo "<input type='hidden' name='loadType' id='loadType' value='$load'/>";
echo "<input type='hidden' name='price' id='price' value='($iPrice) + ($total)'/>" . "<br />";
echo "<input type=submit value=Confirm>";
 
 
 
 
 
 
?>
</form>
 
</body>
 
</html>
 

Dont know why its not working properly as said before its fine on my localhost. Hope someone can help.

Cheers guys
User avatar
phpserver
Forum Newbie
Posts: 22
Joined: Mon Oct 20, 2008 2:59 am
Location: Eastleigh,Nairobi

Re: Problems with my site once uploaded online

Post by phpserver »

dthomas31uk wrote:Hi. Have developed a form that connects with my database using PHP. All of it works great on my localhost, but when I have uploaded it to my server it aint doing the same thing. First off you select the date, thats ok, then you select a country from the drop down list it sees the countries in the database, but when you select it from the drop down list is cannot locate it and comes up with page not found error. Any ideas what I am doing wrong guys.
Here is a link to the page concerned online
http://www.gostoke.eu/eu_home.php

And here is the code. The following is the euhome.php

Code: Select all

<?php
$dbservertype='mysql';
$servername='localhost';
// username and password to log onto db server
$dbusername='**********';
$dbpassword='**********';
// name of database
$dbname='dthomas_europe';
 
////////////////////////////////////////
////// DONOT EDIT BELOW  /////////
///////////////////////////////////////
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
//////// End of connecting to database ////////
?>
 
<!doctype html public "-//w3c//dtd html 3.2//en">
 
<html>
 
<head>
<title>Multiple drop down list box from plus2net</title>
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='dd.php?cat=' + val ;
}
</script>
 
</head>
 
<body>
<form method=post name=f1 action='dd-check.php'>
 
<select name = 'day' class="listBox" tabindex="4" >
    <?php
    // generate day numbers
    for ($x = 1; $x <= 31; $x++) {
        echo "<option value = $x>$x</option>";
    }
    ?>
    </select>
    <select name = 'month' class="listBox" tabindex="4" >
    <?php
    // generate month names
    for ($x = 1; $x <= 12; $x++) {
        echo "<option value=$x>".date('F', mktime(0, 0, 0, $x, 1, 1)).'</option>';
    }
    ?>
    </select>
    <select name = 'year' class="listBox" tabindex="4" >
    <?php
    // generate year values
    for ($x = 2007; $x <= 2008; $x++) {
        echo "<option value=$x>$x</option>";
    }
    ?>
    </select> 
<br />
 
<?
 
/*
If register_global is off in your server then after reloading of the page to get the value of cat from query string we have to take special care.
To read more on register_global visit.
  http://www.plus2net.com/php_tutorial/re ... lobals.php
*/
//@$cat=$_GET['cat']; // Use this line or below line if register_global is off
@$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off
 
///////// Getting the data from Mysql table for Pick Up list box//////////
$querPick=mysql_query("SELECT city, id FROM uk_place");
if (!$querPick) {
exit('<p>Unable to obtain category list from the '  .
       'database.</p>');
} 
///////////// End of query for first list box////////////
 
 
 
///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT country,id FROM eu_place order by country"); 
///////////// End of query for first list box////////////
 
/////// for second drop down list we will check if category is selected else we will display all the subcategory///// 
if(isset($cat) and strlen($cat) > 0){
$quer=mysql_query("SELECT DISTINCT city FROM eu_place where id=$cat order by city"); 
}else{$quer=mysql_query("SELECT DISTINCT city FROM eu_place order by city"); } 
////////// end of query for second subcategory drop down list box ///////////////////////////
 
 
 
 
/// Add your form processing page address to action in above line. Example  action=dd-check.php////
//////////        Starting of first drop downlist /////////
echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
echo mysql_error();
while($noticia2 = mysql_fetch_array($quer2)) { 
if($noticia2['id']==@$cat){echo "<option selected value='$noticia2[id]'>$noticia2[country]</option>"."<BR>";}
else{echo  "<option value='$noticia2[id]'>$noticia2[country]</option>";}
}
echo "</select>"."<BR>";
//////////////////  This will end the first drop down list ///////////
 
 
 
//////////        Starting of second drop downlist /////////
echo "<select name='subcat'><option value=''>Select one</option>";
while($noticia = mysql_fetch_array($quer)) { 
echo  "<option value='$noticia[city]'>$noticia[city]</option>";
}
echo "</select>"."<BR>";
//////////////////  This will end the second drop down list ///////////
 
 
 
echo 'Load from 14m3 - 20m3' . "<label><input type='radio' name='load' value='luton'</label>"."<BR>";
echo 'Load from 7m3 - 14m3'."<label><input type='radio' name='load' value='full_load'</label>"."<BR>";
echo 'Load from 1m3 - 7m3' . "<label><input type='radio' name='load' value='half_load'</label>"."<BR>";
 
 
//////////        Starting of second drop downlist /////////
echo "<select name='pickup'><option value=''>Select one</option>";
while($pickup = mysql_fetch_array($querPick)) { 
echo  "<option value='$pickup[city]'>$pickup[city]</option>";
}
echo "</select>"."<BR>";
//////////////////  This will end the second drop down list ///////////
 
 
//// Add your other form fields as needed here/////
echo "<input type=submit value=Submit>";
 
?>
 
</form>
 

and this is for the next page that organises the form data 'dd-check.php'

Code: Select all

<?php
include 'http://www.gostoke.eu/eu_home.php';
?>
 
 
 
<!doctype html public "-//w3c//dtd html 3.2//en">
 
<html>
 
<head>
<title>Demo Multiple drop down list box from plus2net</title>
</head>
 
<body>
 
<?php
$pickup=$_POST['pickup'];
$cat=$_POST['cat'];
$subcat=$_POST['subcat'];
$load=$_POST['load'];
$appointment_date = sprintf('%02d-%02d-%04d',$_POST['day'], $_POST['month'], $_POST['year']); //mm-dd-yyyy
echo "Date required $appointment_date"."<BR>";
echo "Picking up from $pickup" ."<BR>";
echo "Going to $subcat"."<BR>";
 
 
 
 
$result = mysql_query("SELECT full_price, half_price, luton FROM eu_place WHERE city = '" . mysql_real_escape_string($subcat) . "'") or die(mysql_error());
$row = mysql_fetch_array($result);
 
switch($load) {
    case 'full_load' :
    $total = $row['full_price'];
    break;
    case 'half_load' :
    $total = $row['half_price'];
    break;
    case 'luton':
    $total = $row['luton'];
    break;
   
} 
 
 
$rResult = mysql_query("SELECT price FROM uk_place WHERE city = '" . mysql_real_escape_string($pickup) . "'") or die(mysql_error());
while ($aRow = mysql_fetch_array($rResult, MYSQL_ASSOC))
{
    $iPrice = $aRow['price'];
    echo "£";
    echo ($iPrice) + ($total)."<BR>";
}
 
echo "<form method=post name=f2 action='confirm.php'>";
echo 'To confirm the above details, please enter your details below and click submit' . "<br />";
echo  'Full Name' . "<input type='text' name='name' id='name'/>" . "<br />"; 
echo  'Telephone Number' . "<input type='text' name='telephone' id='telephone'/>" . "<br />"; 
echo  'Email' . "<input type='text' name='email' id='email'/>" . "<br />";
echo 'Comments:' ."<textarea id='textareainput' name='textareainput' rows='10' cols='22'></textarea>";
echo "<input type='hidden' name='date' id='date' value='$appointment_date'/>";
echo "<input type='hidden' name='pickUpPoint' id='pickUpPoint' value='$pickup'/>";
echo "<input type='hidden' name='destination' id='destination' value='$subcat'/>";
echo "<input type='hidden' name='loadType' id='loadType' value='$load'/>";
echo "<input type='hidden' name='price' id='price' value='($iPrice) + ($total)'/>" . "<br />";
echo "<input type=submit value=Confirm>";
 
 
 
 
 
 
?>
</form>
 
</body>
 
</html>
 

Dont know why its not working properly as said before its fine on my localhost. Hope someone can help.

Cheers guys
I noticed you are using localhost for server name.Since you are now over the internet,i think you ought to change localhost to something else like http://www.yourdomain.eu.Secondly,i noticed your javascrpt is doing some fancy things while displaying a dropdown menu,what i would do if it was i,just enum all the fields i want displayed on my listbox display my listbox first and javascript should come later.

______________________________________________________
http://www.atomuss.com
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Problems with my site once uploaded online

Post by requinix »

Code: Select all

self.location='dd.php?cat=' + val ;
Are you sure it's called "dd.php"? Because there isn't one.
Post Reply