:S
Hi,
I am terribly stuck with this code. It is suposed to upload my images to the mysql database with the foreign key(property_id). At first it worked, then later started giving serious errors where the web page could not load. I am lost. Can any one help me, solve this...please:confused: . Below is the code snippet.

<form method="post" enctype="multipart/form-data">
                                                                                    <table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
                                                                                        <tr>
                                                                                            <td class="formText">Property Description:&nbsp;&nbsp;
                                                                                                <select name="userfile">
                                                                                                    <?php
                                                                                                        do {
                                                                                                        ?>
                                                                                                    <option value="<?php echo $row_cust['property_id']?>">
                                                                                                        <?php echo $row_cust['description']?>
                                                                                                    </option>
                                                                                                    <?php
                                                                                                    } while ($row_cust = mysql_fetch_assoc($cust));
                                                                                                    $rows = mysql_num_rows($cust);
                                                                                                    if($rows > 0) {
                                                                                                        mysql_data_seek($cust, 0);
                                                                                                        $row_cust = mysql_fetch_assoc($cust);
                                                                                                    }
                                                                                                ?>
                                                                                            </select></td>
                                                                                            <td width="125">                                                                                            </td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <td>&nbsp;</td>
                                                                                            <td></td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <td width="218">
                                                                                                <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
                                                                                                <input name="userfile" type="file" id="userfile">
                                                                                            </td>
                                                                                            <td width="125"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <td class="text" colspan="2">
                                                                                                <?php
                                                                                                    if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
                                                                                                    {
                                                                                                        $fileName = $_FILES['userfile']['name'];
                                                                                                        $tmpName  = $_FILES['userfile']['tmp_name'];
                                                                                                        $fileSize = $_FILES['userfile']['size'];
                                                                                                        $fileType = $_FILES['userfile']['type'];
                                                                                                        $pid = $_POST['userfile']['property_id'];
                                                                                                
                                                                                                        $fp      = fopen($tmpName, 'r');
                                                                                                        $content = fread($fp, filesize($tmpName));
                                                                                                        $content = addslashes($content);
                                                                                                        fclose($fp);
                                                                                                
                                                                                                        if(!get_magic_quotes_gpc())
                                                                                                        {
                                                                                                            $fileName = addslashes($fileName);
                                                                                                        }
                                                                                                
                                                                                                        include 'library/config.php';
                                                                                                        include 'library/opendb.php';
                                                                                                
                                                                                                        $query = "INSERT INTO upload (property_id, name, size, type, content ) ".
                                                                                                                                                                                                          "VALUES ('$pid', '$fileName', '$fileSize', '$fileType', '$content')";
                                                                                                
                                                                                                        mysql_query($query) or die('Error, query failed'); 

                                                                                                        include 'library/closedb.php';
                                                                                                
                                                                                                        echo "<br>$fileName has been uploaded Successfully <br>";
                                                                                                    }
                                                                                                ?>
                                                                                            </td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <td class="text" colspan="2"><a href="submit_thanks.php">Continue</a>, if done with image uploads.</td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <td colspan="2">&nbsp;</td>
                                                                                        </tr>
                                                                                    </table>
                                                                                </form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.