SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error in error_log causing PHP to not insert data

    Hello, sorry to make 2 topics in one day.

    I keep getting these errors in my error_log, they are causing my PHP to not insert any data into the table. I installed PHP, Apache and MySQL on my computer so I'm using localhost. The problem is that these files already exist in my PHP folder.

    php.png

    Code:
    [10-Jan-2014 10:22:54 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\dev\progs\PHP\ext\php_oci8.dll' - The specified module could not be found.
    
     in Unknown on line 0
    
    [10-Jan-2014 10:22:54 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\dev\progs\PHP\ext\php_oci8_11g.dll' - The specified module could not be found.
    
     in Unknown on line 0
    
    [10-Jan-2014 10:22:55 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\dev\progs\PHP\ext\php_oci8.dll' - The specified module could not be found.
    
     in Unknown on line 0
    
    [10-Jan-2014 10:22:55 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\dev\progs\PHP\ext\php_oci8_11g.dll' - The specified module could not be found.
    
     in Unknown on line 0
    
    [10-Jan-2014 21:21:07 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\dev\progs\PHP\ext\php_oci8.dll' - The specified module could not be found.
    
     in Unknown on line 0
    
    [10-Jan-2014 21:21:07 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\dev\progs\PHP\ext\php_oci8_11g.dll' - The specified module could not be found.
    
     in Unknown on line 0
    
    [10-Jan-2014 21:21:08 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\dev\progs\PHP\ext\php_oci8.dll' - The specified module could not be found.
    
     in Unknown on line 0
    
    [10-Jan-2014 21:21:08 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\dev\progs\PHP\ext\php_oci8_11g.dll' - The specified module could not be found.
    
     in Unknown on line 0

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    I don't know the cause of that error but there is a way to suppress it if you don't need the oracle adaptor. If you don't need the oracle adaptor go into the php.ini file and comment out the oracle extension. Once that is done restart apache. That should prevent PHP from attempting to load the oracle dlls. I think the oracle extension is oci8.so. So search for that in the php.ini and comment is out.
    The only code I hate more than my own is everyone else's.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, it's not giving me an error anymore. But I still can't insert data via PHP and HTML. Although I can update a record though. It's really weird. Do you need my php.ini to see why it's not inserting any data?

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    Is the path to ext set in the php.ini file under
    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Paths and Directories ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;
    .......
    ; Directory in which the loadable extensions (modules) reside.
    ; http://php.net/extension-dir
    ; extension_dir = "./"
    ; On windows:
    ; extension_dir = "ext"

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, the extension folder is uncommented and it points to my extension folder under my PHP folder.
    Here's what I have.

    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Paths and Directories ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ; UNIX: "/path1:/path2"
    ;include_path = ".:/php/includes"
    ;
    ; Windows: "\path1;\path2"
    ;include_path = ".;c:\php\includes"
    ;
    ; PHP's default setting for include_path is ".;/path/to/php/pear"
    ; http://php.net/include-path
    
    ; The root of the PHP pages, used only if nonempty.
    ; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
    ; if you are running php as a CGI under any web server (other than IIS)
    ; see documentation for security issues.  The alternate is to use the
    ; cgi.force_redirect configuration below
    ; http://php.net/doc-root
    doc_root =
    
    ; The directory under which PHP opens the script using /~username used only
    ; if nonempty.
    ; http://php.net/user-dir
    user_dir =
    
    ; Directory in which the loadable extensions (modules) reside.
    ; http://php.net/extension-dir
    ; extension_dir = "./"
    ; On windows:
     extension_dir = "C:\dev\progs\PHP\ext"

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    Maybe missing dependency?
    http://www.php.net/manual/en/oci8.requirements.php

    http://www.php.net/manual/en/install...extensions.php
    Some of the extensions need extra DLLs to work. Couple of them can be found in the distribution package, in the C:\php\dlls\ folder in PHP 4 or in the main folder in PHP 5, but some, for example Oracle (php_oci8.dll) require DLLs which are not bundled with the distribution package. If you are installing PHP 4, copy the bundled DLLs from C:\php\dlls folder to the main C:\php folder. Don't forget to include C:\php in the system PATH (this process is explained in a separate FAQ entry).

  7. #7
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,016
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by therockers View Post
    Thanks, it's not giving me an error anymore. But I still can't insert data via PHP and HTML. Although I can update a record though. It's really weird. Do you need my php.ini to see why it's not inserting any data?
    Can you please post:
    * The structure of the table(s) concerend
    * A sample UPDATE query
    * A sample INSERT query
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  8. #8
    SitePoint Enthusiast
    Join Date
    Dec 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    Can you please post:
    * The structure of the table(s) concerend
    * A sample UPDATE query
    * A sample INSERT query
    This isn't the exact one, but it's about 90% off the original.

    Here is my table
    Code:
    CREATE TABLE IF NOT EXISTS `comments` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `author` varchar(255) NOT NULL,
      `comments` longtext NOT NULL,
      `date` varchar(255) NOT NULL,
      `month` varchar(255) NOT NULL,
      `year` varchar(255) NOT NULL,
      `time` varchar(255) NOT NULL,
      `timestamp` int(11) NOT NULL,
      `select_option` varchar(255) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
    Here is my PHP Update
    Code:
    <?php
    if($_SERVER['REQUEST_METHOD'] == "POST") {
    $mysqli = new mysqli("localhost", "admin", "password", "database');
    if($mysqli->connect_errno) {
    	echo "Error. Please fix.";
    }
    
    $id = $mysqli->real_escape_string($_GET['id']);
    
    $comments = $mysqli->real_escape_string($_POST['comments']);
    
    $update_id = $mysqli->query("SELECT * FROM comments WHERE id = '$id'");
    
    $update_id2 = $mysqli->query("UPDATE comments SET `comments` = '$comments' WHERE id = '$id'");
    
    header("Location:"  . $_SERVER['HTTP_REFERER']);
    }
    ?>
    Here is my PHP Insert
    Code:
    <?php
    if($_POST["comments"] == "") {
    	echo "Empty";
    } else {
    
    	$mysqli = new mysqli("localhost", "admin", "password", "database');
    	if($mysqli->connect_errno) {
    		echo "Error. Please fix.";
    	}
    
    	$table = $mysqli->real_escape_string("comments");
    
    	$comments = $_POST["comment"];
    	$selectoption = $mysqli->real_escape_string($_POST['selectoption']);
    
    	// INSERT INTO DATABASE
    	if($comments || $selectoption) {
    
    		$mysqli = new mysqli("localhost", "admin", "password", "database');
    		if($mysqli->connect_errno) {
    			echo "Error. Please fix.";
    		}
    
    		$selectoption = $mysqli->real_escape_string($selectoption);
    		$t = $mysqli->real_escape_string(time());
    		$d = $mysqli->real_escape_string(date("j"));
    		$m = $mysqli->real_escape_string(date("F"));
    		$y = $mysqli->real_escape_string(date("Y"));
    		$full_date = $mysqli->real_escape_string(date("l, F j, Y"));
    		$update_query = $mysqli->query("INSERT INTO `$table` (`author`, `comments`, `date`, `month`, `year`, `time`, `timestamp`, `select_option`) VALUES ('$session->id', '$comment', '$d', '$m', '$y', '$full_date', '$t', '$selectoption');");
    	}
    }
    ?>
    I've had tons of inserts and tons of updates and I know that it's not because of my code. It's because of my php.ini or the extensions. I've uploaded my files on multiple live hosters including 000webhost just to check if it was my files or my php.ini. I downloaded PHP Version 5.3 and I wanted to use it because I wanted to work with the settings I have on my live website. My web host doesn't support PHP Version 5.4 + so I have to work with the old version. This live website is a total separate live website from the one I've set up on 000webhost. The one on 000webhost is just to check if I was having problems and if my files worked correctly. I've also tried this on freehostia.com as well. I get good results and everything works fine. But when I work on it on my localhost, I get no inserts. Same files, just different directory targets.

  9. #9
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    I'm curious, your update uses both GET and POST ?

  10. #10
    SitePoint Enthusiast
    Join Date
    Dec 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    I'm curious, your update uses both GET and POST ?
    Yes, I didn't want to update my records on the same page so I did GET and POST.
    An example of how I use it.

    Code:
    <?php
    $id = $_GET['id'];
    ?>
    
    <!-- The below is to show which page the user is on and it will echo out the id from the URL. -->
    <form action="newfile.php?id=<?php echo $id; ?>" method="POST" name="form">
    <input type="hidden" author="<?php echo $_SESSION['username']; ?>">
    <textarea name="comments" style="width: 500px; height: 150px;"></textarea>
    <a href="#" onclick="document.form.submit(); return false;">
    </form>
    Then in the actual update page, it has the GET and it looks like how I coded it. What I'm trying to do is getting the ID from the submit page and putting it in a page solely only for updating. I don't want to put the update page on the same page that already has an isset. Plus to me, it's kind of clumsy if I smash together all of my codes on one page.

  11. #11
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    The table schema has NOT NULL for the fields, but the insert is testing for $comments or $selectoption
    If one is NULL the insert would fail. But I don't know how that would cause oracle dll errors

    Maybe $session->id (the author varchar) is failing only for localhost?

  12. #12
    SitePoint Enthusiast
    Join Date
    Dec 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    The table schema has NOT NULL for the fields, but the insert is testing for $comments or $selectoption
    If one is NULL the insert would fail. But I don't know how that would cause oracle dll errors

    Maybe $session->id (the author varchar) is failing only for localhost?
    No. $session->id is suppose to be $session->username. I wrote that part wrong since that was an edit off the original. The original has $session->username. But this isn't the case. I've tried a much simpler code to test if it inserts into my database. Here is the simple code I've tested.

    This is the simple structure.
    Code:
    CREATE TABLE IF NOT EXISTS `table` (
      `firstrow` varchar(255) NOT NULL,
      `secondrow` varchar(255) NOT NULL,
      `thirdrow` varchar(255) NOT NULL,
      `fourthrow` varchar(255) NOT NULL,
      `fifthrow` longtext NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    I'm using text fields and text areas to indicate that both text and area is going to be used.

    Code:
    <?php
    // kskmzpl is just to check if the form has been submitted.
    if(isset($_POST['kskmzpl'])) {
    
    // Database information
    $mysqli = new mysqli("localhost", "admin", "password", "database");
    if($mysqli->connect_errno) {
    echo "Error connecting to database, please fix.";
    }
    
    // Escape all $_POST so no SQL Injections can happen.
    $firstrow = $mysqli->real_escape_string($_POST['firstrow']);
    $secondrow = $mysqli->real_escape_string($_POST['secondrow']);
    $thirdrow = $mysqli->real_escape_string($_POST['thirdrow']);
    $fourthrow = $mysqli->real_escape_string($_POST['fourthrow']);
    $fifthrow = $mysqli->real_escape_string($_POST['fifthrow']);
    
    // Finally insert all data
    $query = $mysqli->query("INSERT INTO table (`firstrow`, `secondrow`, `thirdrow`, `fourthrow`, `fifthrow`) VALUES ('$firstrow', '$secondrow', '$thirdrow', '$fourthrow', '$fifthrow')");
    
    }
    ?>
    
    
    <form action="" method="POST">
    <input type="hidden" name="kskmzpl">
    <input type="text" name="firstrow" value="">
    <input type="text" name="secondrow" value="">
    <input type="text" name="thirdrow" value="">
    <input type="text" name="fourthrow" value="">
    <textarea name="fifthrow" rows="6" columns="10"></textarea>
    <button type="submit">Submit</button>
    </form>
    Even after this simple code, it still won't insert into my database. If I don't escape anything and just use plain PHP insert and HTML, I will still get the same results. It won't insert at all. I want to figure out the problem because the home page is what deals with inserting data. The home page is where people post things.

  13. #13
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,016
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Have you used session_start() at somepoint before trying to get the session id? Where are you getting a value for $session->id from?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  14. #14
    SitePoint Enthusiast
    Join Date
    Dec 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    Have you used session_start() at somepoint before trying to get the session id? Where are you getting a value for $session->id from?
    Yes, I have. In the original files, session_start() has already been set and $session->id wasn't suppose to be in this edit. It's just suppose to be the author's ID or the author's username. $session->id is a replacement for the global $_SESSION variable. I can try making a video and showing the actual footage of what's happening and the results I'm getting. I will use the original files in the video.

  15. #15
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,016
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Change the bit where you run the insert query to:

    PHP Code:
    // Finally insert all data
    $query $mysqli->query("INSERT INTO table (`firstrow`, `secondrow`, `thirdrow`, `fourthrow`, `fifthrow`) VALUES ('$firstrow', '$secondrow', '$thirdrow', '$fourthrow', '$fifthrow')");
    $sql="
        INSERT INTO
            table
        (
              `firstrow`
            , `secondrow`
            , `thirdrow`
            , `fourthrow`
            , `fifthrow`
        )
            VALUES
                (
                      '
    $firstrow'
                    , '
    $secondrow'
                    , '
    $thirdrow'
                    , '
    $fourthrow'
                    , '
    $fifthrow'
                )
    "
    ;
    if (!
    $mysqli->query($sql)) {
        
    printf("Errormessage: %s\n"$mysqli->error);

    By doing it that way you can echo $query to see exactly what's being sent to MySQL and the last bit displays any error that MySQL is giving. In the long run you should consider switching over to using prepared statements (which take the place of $mysqli->real_escape_string).

    A likely culprit is the use of "table" for the name of the table as "table" is a reserved word.
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  16. #16
    SitePoint Enthusiast
    Join Date
    Dec 2013
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    Change the bit where you run the insert query to:

    PHP Code:
    // Finally insert all data
    $query $mysqli->query("INSERT INTO table (`firstrow`, `secondrow`, `thirdrow`, `fourthrow`, `fifthrow`) VALUES ('$firstrow', '$secondrow', '$thirdrow', '$fourthrow', '$fifthrow')");
    $sql="
        INSERT INTO
            table
        (
              `firstrow`
            , `secondrow`
            , `thirdrow`
            , `fourthrow`
            , `fifthrow`
        )
            VALUES
                (
                      '
    $firstrow'
                    , '
    $secondrow'
                    , '
    $thirdrow'
                    , '
    $fourthrow'
                    , '
    $fifthrow'
                )
    "
    ;
    if (!
    $mysqli->query($sql)) {
        
    printf("Errormessage: %s\n"$mysqli->error);

    By doing it that way you can echo $query to see exactly what's being sent to MySQL and the last bit displays any error that MySQL is giving. In the long run you should consider switching over to using prepared statements (which take the place of $mysqli->real_escape_string).

    A likely culprit is the use of "table" for the name of the table as "table" is a reserved word.
    Yes, I've considered learning how to prepare my statements. I've also tried changing table names and that simple code started working so I use the same error message on my code and I started getting value at line 44 undefined so I went and nulled all the columns that weren't being used in the demo. Then I started getting this error.

    Errormessage: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1

    EDIT: Never mind, it's working now. Thanks for the help.


Bookmarks

Posting Permissions

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