php page working localhost fine but not working online

hi frnd’s
php session script working localhost finely but not working online

<?php session_start(); $day=$_SESSION['day']; $car_id=$_POST['ch']; $_SESSION['car_id']=$car_id; mysql_connect("localhost","usabhpal_santosh","mudaliar"); mysql_select_db("usabhpal_gtravel"); $data=mysql_query("select *from cars where car_id=".$_SESSION['car_id'].""); while($info=mysql_fetch_array($data)) { $_SESSION['fare']=$info['fare']; ?>



<

<?php } ?>
Selected Vechicle
' width='150' height='150'/>    Catagory:
   <?php echo $info['catagory']; ?> (INNOVA)

   Usage(Every Day)

   <?php echo $info['services']; ?> Usage

   Days:'size='1' style='background-color:#5D1813;border:none;color:#BC9744' /> days
Travel Information
Pick Up Place:      <?php echo $_SESSION['city1']; ?>
Pick Up Date :      <?php echo $_SESSION['date1']; ?>
Pick Up Time :      <?php echo $_SESSION['time1']; ?>
   
Drop Place :      <?php echo $_SESSION['city2']; ?>
Drop Date :      <?php echo $_SESSION['date2']; ?>
Drop Time :       <?php echo $_SESSION['time2']; ?>
      
Fare Detail
Booking Amount :      <input type='text' name='fare' value=' <?php <p>mysql_connect(“localhost”,“usabhpal_santosh”,“mudaliar”);<br> mysql_select_db(“usabhpal_gtravel”);<br> $data1=mysql_query(" select * from fare_city where car_id=".$_SESSION[‘car_id’]." and ( city1=’".$_SESSION[‘city1’]."’ and city2=’".$_SESSION[‘city2’]."’)");<br> $info= mysql_fetch_array($data1);</p> <p>echo $info[‘fare’]*$day;<br> ?>'size=‘3’ style=‘background-color:#5D1813;border:none;color:#BC9744’ />
Service Tax :      Rs 65
Total Amount :       <?php mysql_connect("localhost","usabhpal_santosh","mudaliar"); mysql_select_db("usabhpal_gtravel"); $data1=mysql_query(" select * from fare_city where car_id=".$_SESSION['car_id']." and ( city1='".$_SESSION['city1']."' and city2='".$_SESSION['city2']."')"); $info= mysql_fetch_array($data1); echo "".(($info['fare']*$day)+65).""; ?>
      
Extra Charges
Extra Amount per hour :      Rs 90
Extra Amount per kms :      Rs 9
                                          <?php $_SESSION['cars']=$info['cars']; $_SESSION['catagory']=$info['catagory']; $_SESSION['capacity']=$info['capacity']; $_SESSION['services']=$info['services']; $_SESSION['fare']=$info['fare']; mysql_close(); ?>

can u help me urgently…thanku

santosh 9039866780

Since we do not have access to your database, we must guess a little on the errors.

First, if it works well offline on your test server and then when moved to the live online server,
did you reset your connection info for your database? Does it actually pull the data from the server’s database?

Also, please place code inside of the PHP tags above. This helps us quickly load your sample into our editors.

Lastly, your question stated that your “session” script was not working. Are you getting ANY session variables passed or are all of them blank? Please let us know if you are seeing any written errors on your live pages.
There are many ways to debug your script, but, we need to know more about the error messages you are receiving first. Then, we can help further!

Also try enabling errors by putting the following at the very start after your first <?php tag:
[php]
ini_set(‘display_errors’, ‘On’);
error_reporting(-1);
[/php]

Hi Santosh. I’m new here also, this is my first post.

Not sure about your errors, but having your username and password to log on to the database hard coded in your script(s) is a bad idea. You should abstract them out into another file, and encrypt the password.

I’m new to php and mysql, and new to a lot of programming. I have an idea for a website that could make a living for me (I had a spinal cord injury and use a wheelchair), and I’m starting from scratch to create one using php mostly, along with html and css and jquery/ajax, etc.

I’ll be asking a ton of questions here, and I appreciate all the help I know I’ll get. Just want to say thanks beforehand to the community.

Sorry for hijacking your thread Santosh, good luck debugging your problems.

try adding ’ or die(mysql_error());’ to the end of each mysql_query, and run your code again. This will report any typo and syntax errors in your query. Once you know the problem it is easy to fix.

This actually makes no difference. It’s only more viable to load your login information from another file, if you use it in multiple files. Also, encrypting the password would result in MySQL returning that your password is wrong since you can’t decrypt it (assuming your talking about md5 or sha1 for encryption)

I’m new, and just starting, going to build a website and learn as I go. But I’ve been working on a few web pages so far, and I’m storing the constants for a connect.php file that uses mysql_connect() - (DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD) in a file that can’t be seen by the web server named config.php.

The few web pages I’ve written (very simple tests) all do mysql queries, so I use “require_once connect.php” in the top of each file. At the top of connect.php I have “require_once config.php”

connect.php has mysql_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD) and connects or errors.

Am I going about this wrong?

Regarding the password, I read it wrong, my mistake, I was thinking about users passwords being encrypted with the crypt() function and using salt to be able to match them up at login, not the connection to the database for queries.

I apologize for getting this thread off track. I’ll start a new thread soon. Thanks

No you’re doing it fine, but it isn’t required, or any safer to use a different file. If you were to goto any file which had the password as this one does, and view source you wouldn’t see the password or anything. The only time it makes a difference, is if the file that’s being included is out of the public html folder, ie you can’t navigate to it in a web-browser.

Thanks RaythXC.

Santosh, did you solve your local vs live site issues? The others seem to only want to talk about login not your problem. They should start their own posts. The main difference in your code is that you must point your connection information to the new online database. You must also, have set up your database before your code will work online. I would guess one of those two is your problem. Let us know if you solved it…

Sponsor our Newsletter | Privacy Policy | Terms of Service