Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12

Thread: Php and Mysql

  1. #1
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Php and Mysql

    I have problem i change my hosting company and right now i can connect with datebases and on php pages is missing formats.On last company
    everything was working good.

  • #2
    Regular Coder Linux_Sage's Avatar
    Join Date
    Mar 2014
    Location
    Sterling,VA
    Posts
    105
    Thanks
    0
    Thanked 10 Times in 10 Posts
    That's too vague. What exactly is happening?

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,603
    Thanks
    0
    Thanked 645 Times in 635 Posts
    What PHP and mySQL versions is your new hosting using and what versions was the old hosting using?

    Are you using mysqli or PDO for the database calls?
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I am using mysqli for databases calls.PHP and mySQL versions Version: 5.5.32 is new hosting company.This is page where i spouse get results you missing You want[ ]rooms . You have [ ]kids. You have[ ]adult.One more thing is not working my code for booking is not echoing on this page $ending = strtotime($_POST['endDate']);
    $starting = strtotime($_POST['startDate']);

    $numberDays = floor(abs($ending -$starting) / 86400);



    echo "You want reserve room number (".$_POST["rooms"].") from " .$_POST['startDate']. " until " .$_POST['endDate']. " in period of " .ceil($numberDays). " day(s) and ".ceil($numberDays)." night(s).";
    if($_POST['rooms']=="1"){
    $s1=100;
    }else if ($_POST['rooms']=="2"){
    $s1=200;
    }else if($_POST['rooms']=="3"){
    $s1=300;
    }else if ($_POST['rooms']=="4"){
    $s1=400;
    }
    $price=$numberDays*$s1;

    echo "<div style='text-align:down 1000px'><h1> ". $_SESSION['price']."</h1></div>";

    echo '<br />You have to pay € '.$price;

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,603
    Thanks
    0
    Thanked 645 Times in 635 Posts
    I hope that your live code isn't written like that so as to allow anyone to insert whatever they like into the page (you should validate the $_POST fields and move them to internal fields before using them).

    Are the versions of PHP and mySQL the same as on the old server?

    You still haven't posted enough code to figure out the problem as what you have posted has many fields that have unknown values.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Is same PHP and mySQL version $_POST fields and move them to internal fields before using them i don't get it.


    // Get values from form
    $startDate=$_POST['startDate'];
    $endDate=$_POST['endDate'];

    $rooms=$_POST['rooms'];
    $kids=$_POST['kids'];
    $adult=$_POST['adult'];
    // Insert data into mysql

    $sql="INSERT INTO adult(startDate,endDate, rooms, kids,adult,numberdays)VALUES('$startDate','$endDate', '$rooms', '$kids','$adult','$numberdays')";
    $result=mysql_query($sql);






    if($result){
    echo "succesfull";
    echo "<BR>";
    echo "<a href=''></a>";
    }

    else {
    echo "ERROR";
    }










    ?>
























    <?php
    $ending = strtotime($_POST['endDate']);
    $starting = strtotime($_POST['startDate']);

    $numberDays = floor(abs($ending -$starting) / 86400);



    echo "You want reserve room number (".$_POST["rooms"].") from " .$_POST['startDate']. " until " .$_POST['endDate']. " in period of " .ceil($numberDays). " day(s) and ".ceil($numberDays)." night(s).";
    if($_POST['rooms']=="1"){
    $s1=100;
    }else if ($_POST['rooms']=="2"){
    $s1=200;
    }else if($_POST['rooms']=="3"){
    $s1=300;
    }else if ($_POST['rooms']=="4"){
    $s1=400;
    }
    $price=$numberDays*$s1;

    echo "<div style='text-align:down 1000px'><h1> ". $_SESSION['price']."</h1></div>";

    echo '<br />You have to pay € '.$price;



    if( $vr2 < "0" )
    {


    }

    {


    }


    //$_POST['brojDana']=$brojDana;





















    ?>
    </span>


    <p class="nn">&nbsp;<?php echo $row_Recordset1['']; ?>; ?><?php echo $row_Recordset1['ID']; ?></p>
    <?php

    echo "<div style='text-align:down 1000px'><h1> ". $_SESSION['rooms,you,have,kids,you, have,adult']."</h1></div>";
    ?>
    <h3>You want[ <?php echo $row_Recordset1['rooms']; ?> ]rooms . You have [ <?php echo $row_Recordset1['kids']; ?> ]kids. You have[ <?php echo $row_Recordset1['adult']; ?> ]adult.








  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,603
    Thanks
    0
    Thanked 645 Times in 635 Posts
    $startDate=$_POST['startDate'];

    should be

    if (validStartDate($_POST['startDate']) $startDate=$_POST['startDate'];
    else echo "Start Date is Invalid";

    and so on - otherwise someone can post whatever they like as start date - for example an SQL command to drop your database.

    That is basic PHP security - almost a prerequisite for PHP for beginners.


    Also you ought to check if the new server still has mysql_ calls enabled as that antiquated interface has been flagged for removal as it has been replaced by mysqli_ calls or by PDO.

    Another thing to check is whether your database is defined correctly on the new hosting the way you had it on the old hosting - also is the same user and password set up to allow the connection?
    Last edited by felgall; 04-26-2014 at 03:07 AM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #8
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    $startDate=$_POST['startDate'];

    should be

    if (validStartDate($_POST['startDate']) $startDate=$_POST['startDate'];
    else echo "Start Date is Invalid";

    and so on - otherwise someone can post whatever they like as start date - for example an SQL command to drop your database.

    That is basic PHP security - almost a prerequisite for PHP for beginners.


    Also you ought to check if the new server still has mysql_ calls enabled as that antiquated interface has been flagged for removal as it has been replaced by mysqli_ calls or by PDO.

    Another thing to check is whether your database is defined correctly on the new hosting the way you had it on the old hosting - also is the same user and password set up to allow the connection?

    New server do not support mysql_ calls
    they are different username and password i did changed that.One more thing is when insert date in form and hit submit button informations they are going in 3 rows datebase spouse to go in just one row little be strange.I got connection with database.

  • #9
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts
    any helpppp

  • #10
    Regular Coder Linux_Sage's Avatar
    Join Date
    Mar 2014
    Location
    Sterling,VA
    Posts
    105
    Thanks
    0
    Thanked 10 Times in 10 Posts
    If your host supposedly doesn't support mysql_ calls then why are you using them?

  • #11
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Linux_Sage View Post
    If your host supposedly doesn't support mysql_ calls then why are you using them?



    I am not sure about that they told me also they don't support connection between dreamweaver and my sql datebases but i did got connection.sqli_calls i have beeen using because i know that about another calls i am not sure.
    Last edited by Pearl_9; 04-26-2014 at 05:47 PM.

  • #12
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Why this code not working on new hosting account


    <?php
    $ending = strtotime($_POST['endDate']);
    $starting = strtotime($_POST['startDate']);

    $numberDays = floor(abs($ending -$starting) / 86400);



    echo "You want reserve room number (".$_POST["rooms"].") from " .$_POST['startDate']. " until " .$_POST['endDate']. " in period of " .ceil($numberDays). " day(s) and ".ceil($numberDays)." night(s).";
    if($_POST['rooms']=="1"){
    $s1=100;
    }else if ($_POST['rooms']=="2"){
    $s1=200;
    }else if($_POST['rooms']=="3"){
    $s1=300;
    }else if ($_POST['rooms']=="4"){
    $s1=400;
    }
    $price=$numberDays*$s1;

    echo "<div style='text-align:down 1000px'><h1> ". $_SESSION['price']."</h1></div>";

    echo '<br />You have to pay € '.$price;



    if( $vr2 < "0" )
    {


    }

    {


    }


    //$_POST['brojDana']=$brojDana;





















    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •