SQL Function works in 5.0, not 4.4.1

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • byrd.48@rocketmail.com

    SQL Function works in 5.0, not 4.4.1

    Hi,
    I have the following functions which work on my home server (IIS 5.0,
    PHP5.1, MySQL 5) but not on the production server (Linux Apache Zend,
    PHP 4.4.1, MySQL 4.1.13). From what I can see, I'm connecting to the
    database, but the sql passed to it is not working on the prod server.
    Any help would be much appreciated, I'm a newbie from .NET.
    It may be difficult to read from the code below, but when I'm inserting
    the variables into the sql string, I'm using double quotes then single
    quotes as in:

    ' INSERT INTO ... " ' . $VARIABLE . ' "

    Thank you in advance.

    Jon


    // test.php
    include('users4 x.php');
    $users = new users();
    $users->User_InsertNew ('Jon', 'byrd', 'jb@nospam.net' , 'byrd', '0');



    // users4x.php
    class users{

    function User_InsertNew( $UserFirstName, $UserLastName, $UserEmail,
    $UserPassword,$ ActInact){
    global $dbuser, $dbuserpass, $dbserver, $db;
    $sql='INSERT INTO `Users`(`UserFi rstName`, `UserLastName`,
    `UserEmail`, `UserPassword`, `ActInact`)
    VALUES("'.$User FirstName.'","' .$UserLastName. '","'.$UserEmai l.'","'.$UserPa ssword.'","'.$A ctInact.'");';
    $connection = mysql_connect($ dbserver, $dbuser, $dbuserpass) or die
    ("Could not connect to server");
    $catalog = mysql_select_db ($db);
    $result = mysql_query($sq l);
    mysql_close();
    }

    }

  • Dikkie Dik

    #2
    Re: SQL Function works in 5.0, not 4.4.1

    After calling the mysql_query function, you can call the mysql_errno
    and/or mysql_error to see what errors are returned by the database
    server. Personally, I log all errors: storing them in an errorlog table
    or (if there is no database connection) sending them by e-mail.

    Best regards

    byrd.48@rocketm ail.com wrote:[color=blue]
    > Hi,
    > I have the following functions which work on my home server (IIS 5.0,
    > PHP5.1, MySQL 5) but not on the production server (Linux Apache Zend,
    > PHP 4.4.1, MySQL 4.1.13). From what I can see, I'm connecting to the
    > database, but the sql passed to it is not working on the prod server.
    > Any help would be much appreciated, I'm a newbie from .NET.
    > It may be difficult to read from the code below, but when I'm inserting
    > the variables into the sql string, I'm using double quotes then single
    > quotes as in:
    >
    > ' INSERT INTO ... " ' . $VARIABLE . ' "
    >
    > Thank you in advance.
    >
    > Jon
    >
    >
    > // test.php
    > include('users4 x.php');
    > $users = new users();
    > $users->User_InsertNew ('Jon', 'byrd', 'jb@nospam.net' , 'byrd', '0');
    >
    >
    >
    > // users4x.php
    > class users{
    >
    > function User_InsertNew( $UserFirstName, $UserLastName, $UserEmail,
    > $UserPassword,$ ActInact){
    > global $dbuser, $dbuserpass, $dbserver, $db;
    > $sql='INSERT INTO `Users`(`UserFi rstName`, `UserLastName`,
    > `UserEmail`, `UserPassword`, `ActInact`)
    > VALUES("'.$User FirstName.'","' .$UserLastName. '","'.$UserEmai l.'","'.$UserPa ssword.'","'.$A ctInact.'");';
    > $connection = mysql_connect($ dbserver, $dbuser, $dbuserpass) or die
    > ("Could not connect to server");
    > $catalog = mysql_select_db ($db);
    > $result = mysql_query($sq l);
    > mysql_close();
    > }
    >
    > }
    >[/color]

    Comment

    • Andy Hassall

      #3
      Re: SQL Function works in 5.0, not 4.4.1

      On 30 Dec 2005 12:27:39 -0800, byrd.48@rocketm ail.com wrote:
      [color=blue]
      >function User_InsertNew( $UserFirstName, $UserLastName, $UserEmail,
      >$UserPassword, $ActInact){
      > global $dbuser, $dbuserpass, $dbserver, $db;
      > $sql='INSERT INTO `Users`(`UserFi rstName`, `UserLastName`,
      >`UserEmail`, `UserPassword`, `ActInact`)
      >VALUES("'.$Use rFirstName.'"," '.$UserLastName .'","'.$UserEma il.'","'.$UserP assword.'","'.$ ActInact.'");';
      > $connection = mysql_connect($ dbserver, $dbuser, $dbuserpass) or die
      >("Could not connect to server");[/color]

      mysql_error() would add more useful information to the error message.
      [color=blue]
      > $catalog = mysql_select_db ($db);[/color]

      Check that this succeeds, similar to the mysql_connect call.
      [color=blue]
      > $result = mysql_query($sq l);[/color]

      Check that this succeeds; it's most likely this is where the error is thrown,
      but you're ignoring it at the moment.
      [color=blue]
      > mysql_close();
      >}[/color]

      --
      Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
      http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

      Comment

      Working...