hi
i am trying to upload image files into the sql database through php
the code is here

but when i am trying to open the test_imagedb.php page i got this error

Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 37

anyone here for help?
why should i get this error????😕

and also tel me what the use of php.ini and my.ini
what do i do with these two files ??

    The tutorial tells you what you must do. The php.ini and my.ini are configuration files so unless you have administrative access you wont have access to these 2 files. However the idea is to increase the file upload filesize.

    Can you copy paste what you have as I do not get any errors when i pasted the code in. Mind you i never did the upload.

      meddycool wrote:

      why should i get this error????

      At a wild guess I'd say it's because somewhere on line 37 of test_imagedb.php you have a number where you should have a variable.

        planetsim

        here is my test_imagedb.php code

        <body>
        <?
        if (!isset($_REQUEST["submit"])) {
        ?>
        <form method="POST" action="<?= $_SERVER["PHP_SELF"] ?>" enctype="application/x-www-form-
        urlencoded">
        <table>
        <tr><td>Type</td><td><select name="imgtype"><option value="image/gif">GIF</option><option
        value="image/jpeg">JPEG</option></select></td></tr>
        <tr><td>File</td><td><input type="file" name="imgfile"></td></tr>
        <tr><td></td><td><input type="submit" name="submit" value="upload"><input type="reset"></td></tr>
        </table>
        </form>
        <?
        //-- save image to db --
        } else {
          /*
          the code below is a suggestion from California Strong...
          */
          $hndl=fopen($_REQUEST["imgfile"],"r");
          $isize=sizeof($_REQUEST["imgfile"]);
        
          $imgdata="";
          while(!feof($hndl)){
            $imgdata.=fread($hndl,$isize);
          };
        
          /*
          my code was...
        
          $hndl=fopen($_REQUEST["imgfile"],"r");
          $imgdata=fread($hndl,filesize($_REQUEST["imgfile"]));
          */
        
          $imgdata=addslashes($imgdata);
        
          $dbconn = @mysql_connect($localhost,$myhotspot_crazy,$159995) or exit("SERVER Unavailable");
          @mysql_select_db($myhotspot_lol,$dbconn) or exit("DB Unavailable");
        
          $sql = "INSERT INTO tblimage VALUES(NULL,'". $_REQUEST["imgtype"] ."','". $imgdata ."')";
        
          @mysql_query($sql,$dbconn) or exit("QUERY FAILED!");
        
          mysql_close($dbconn);
        
          fclose($hndl);
        
          echo "<a href=\"test_imagedb_view.php\">view image</a>";
        };
        ?>
        </body> 

        and i have got this error when opeing the page

        Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 37

        but line 37contain the dbconnection???😕

        others pages code is

        test_imagedb_create.php

        <?php
        $dbconn = @mysql_connect($localhost,$myhotspot_crazy,$159995) or exit("SERVER Unavailable");
        @mysql_select_db($myhotspot_lol,$dbconn) or exit("DB Unavailable");
        
        $sql = "SELECT imgtype,imgdata FROM tblimage WHERE imgid=". $_GET["imgid"];
        
        $result = @mysql_query($sql,$dbconn) or exit("QUERY FAILED!");
        
        $contenttype = @mysql_result($result,0,"imgtype");
        $image = @mysql_result($result,0,"imgdata");
        
        header("Content-type: $contenttype");
        echo $image;
        
        mysql_close($dbconn);
        ?>

        and test_imagedb_view.php
        is as follow

        <body>
        <?
        $dbconn = @mysql_connect($localhost,$myhotspot_crazy,$159995) or exit("SERVER Unavailable");
        @mysql_select_db($myhotspot_lol,$dbconn) or exit("DB Unavailable");
        
        $sql = "SELECT imgid,imgtype FROM tblimage ORDER BY imgid";
        
        $result = @mysql_query($sql,$dbconn) or exit("QUERY FAILED!");
        
        echo "<table border=1>\n";
        echo "<tr><th>imgid</th><th>imgtype</th><th>imgdata</th></tr>\n";
        while ($rs=mysql_fetch_array($result)) {
          echo "<tr><td>".$rs[0]."</td>";
          echo "<td>".$rs[1]."</td>";
          echo "<td><img src=\"test_imagedb_create.php?imgid=".$rs[0]."\"></td></tr>\n";
        };
        echo "</table>\n";
        
        mysql_close($dbconn);
        ?>
        </body>
        
        

          do not start variables with numbers.

          $host='localhost';
          $username='myhotspot_crazy';
          $password='159995';
          $db='myhotspot_lol';
          $dbconn = @mysql_connect($host,$username,$password) or exit("SERVER Unavailable");
          @mysql_select_db($db,$dbconn) or exit("DB Unavailable"); 
            $159995

            is meaningless. Look up [man]variables[/man] in the manual to see what is and what isn't a valid name for a variable.

              Weedpacket;10897886 wrote:
              $159995

              is meaningless. Look up [man]variables[/man] in the manual to see what is and what isn't a valid name for a variable.

              hey that dbpassword right..............???😕

                I don't know if it's the right password; it's your database. But $159995 is not a valid variable.

                  Weedpacket;10897993 wrote:

                  I don't know if it's the right password; it's your database. But $159995 is not a valid variable.

                  tel me some examples like...........what kind of variable i have to insert here?

                    meddycool;10898010 wrote:

                    tel me some examples like...........what kind of variable i have to insert here?

                    lets create variables like $host, $username, $password and $db. Then you can use them in the mysql connection, example:

                    $host='localhost';
                    $username='myhotspot_crazy';
                    $password='159995';
                    $db='myhotspot_lol';
                    $dbconn = @mysql_connect($host,$username,$password) or exit("SERVER Unavailable");
                    @mysql_select_db($db,$dbconn) or exit("DB Unavailable"); 

                      oh...........i am stupid :eek:
                      i forget this :queasy::queasy::queasy:

                        djjjozsi;10898013 wrote:

                        lets create variables like $host, $username, $password and $db. Then you can use them in the mysql connection, example:

                        $host='localhost';
                        $username='myhotspot_crazy';
                        $password='159995';
                        $db='myhotspot_lol';
                        $dbconn = @mysql_connect($host,$username,$password) or exit("SERVER Unavailable");
                        @mysql_select_db($db,$dbconn) or exit("DB Unavailable"); 

                        i have done all this still i am getting an error

                        Warning: fopen() [function.fopen]: Unable to access book.gif in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 20

                        Warning: fopen(book.gif) [function.fopen]: failed to open stream: No such file or directory in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 20

                        Warning: feof(): supplied argument is not a valid stream resource in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 24

                        Warning: fread(): supplied argument is not a valid stream resource in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 25

                          please take a look for this code in my server

                          click here to see

                          and when u hit the upload button it will display the following error

                          Warning: fopen() [function.fopen]: Unable to access Adriana_Karembeu-2.JPG in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 20

                          Warning: fopen(Adriana_Karembeu-2.JPG) [function.fopen]: failed to open stream: No such file or directory in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 20

                          Warning: filesize() [function.filesize]: stat failed for Adriana_Karembeu-2.JPG in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 21

                          Warning: fread(): supplied argument is not a valid stream resource in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 21

                          Notice: Undefined variable: handle in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 43

                          Warning: fclose(): supplied argument is not a valid stream resource in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 43
                          view image

                              $hndl=fopen($_REQUEST["imgfile"],"r");
                              $isize=sizeof($_REQUEST["imgfile"]); 

                            use this:
                            and imgfile if the name how you set the file field in your form:

                              $hndl=fopen($_FILES["imgfile"]["tmp_name"],"r");
                              $isize=sizeof($_FILES["imgfile"]["tmp_name"]); 

                            But i suggest you do not upload files into mysql database.

                              djjjozsi;10898029 wrote:

                              But i suggest you do not upload files into mysql database.

                              but why ??????????😕

                                djjjozsi;10898029 wrote:
                                  $hndl=fopen($_REQUEST["imgfile"],"r");
                                  $isize=sizeof($_REQUEST["imgfile"]); 

                                use this:
                                and imgfile if the name how you set the file field in your form:

                                  $hndl=fopen($_FILES["imgfile"]["tmp_name"],"r");
                                  $isize=sizeof($_FILES["imgfile"]["tmp_name"]); 

                                But i suggest you do not upload files into mysql database.

                                still not working
                                now eror are

                                Notice: Undefined index: imgfile in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 20

                                Notice: Undefined index: imgfile in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 21

                                Notice: Undefined variable: imgdata in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 29

                                Warning: fclose(): supplied argument is not a valid stream resource in /www/obxhost.net/m/y/h/myhotspot/htdocs/test_imagedb.php on line 43

                                check here on my server

                                  Try using:

                                  <form method="POST" action="/test_imagedb.php" enctype="application/x-www-form-urlencoded">

                                  instead of:

                                  <form method="POST" action="/test_imagedb.php" enctype="application/x-www-form-
                                  urlencoded">

                                    bradgrafelman

                                    :eek:
                                    what the different lol

                                      The latter has a line break after the 'form-' part while the former contains no line breaks.

                                        nothing happen same result.....................😕😕