Jump to content

$Three3

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Posts posted by $Three3

  1. I have a PHP contact form on my website. I have been using it for about a year now without any problems. Nothing has been updated on my website that has do to with the contact form. However, all of a sudden, when a user enters "line breaks" or "paragraphs" in the message box, when I receive the message, instead of having several paragraphs I have 1 long paragraph with "\r\n" in place of line breaks.

     

    Here is the code:

     

    $to = "info@mycompany123.com";
    $headers = "From: $email";
    $subject = $subject;
    $body = "Name: $name\n\n"
    . "Email: $email\n\n"
    . "Subject: $subject\n\n"
    . "Message: $message" ;
    
    mail ($to, $subject, $body, $headers) ;

     

     

    For example, if someone fills out my contact form, here is what it looks like in my inbox:

     

    Name: Allen Falcon

     

    Email: allen_falcon@example.com

     

    Subject: Help

     

    Message: Hello,\r\n I would like to know more about you guys program and how it works.\r\n Thanks,\r\n Allen Flacon

     

     

     

    I really do not know why it started doing this out of the blue but any help is greatly appreciated!

  2. Hi everyone, I have a long list of names that I need to have quotes around (it can be double or single quotes) and I have about 8,000 of them. I have them in Excel without any quotes and I can copy all of the names and paste them no problem but there are still no quotes. I have looked and looked for an Excel formula to add quotes to the name in each row but I have had no luck. I have also tried some clever find and replace techniques but no have worked either. The format I am looking for is this:

     

    "Allen" or 'Allen'

     

    Any of those would work. I need this so I can store the info into a database. Any help is greatly appreciated. Thanks

     

     

     

    PS:

     

    I have found other people online needing the same thing done that I need done and this solution has worked for them but I do not know what do with it:

     

    You can fix it by using a range variable (myCell for example) and then use that to iterate the 'selection' collection of range objects, like so

    Sub AddQuote()
    Dim myCell As Range
        For Each myCell In Selection
            If myCell.Value <> "" Then
                myCell.Value = Chr(34) & myCell.Value
            End If
        Next myCell
    End Sub
    

     

     

    Another solution that also worked for others was:

     

    Sub OneUglyExport()
    
    Dim FileToSave, c As Range, OneBigOleString As String
    
    FileToSave = Application.GetSaveAsFilename
    
    Open FileToSave For Output As #1
    
    For Each c In Selection
    
        If Len(c.Text) <> 0 Then _
    
            OneBigOleString = OneBigOleString & ", " & Chr(34) & Trim(c.Text) & Chr(34)
    
    Next
    
    Print #1, Mid(OneBigOleString, 3, Len(OneBigOleString))
    
    Close #1
    
    End Sub
    

  3. "/users/$directory"

     

    A leading / on a file system path refers to the root of the current hard disk. I suspect that you want - "users/$directory" or that you want to form an absolute file system path made up of your document root path followed by /users/$directory

     

    Thanks a lot man. That worked perfectly.

  4. Hi everyone, I am stuck on a simple script. I have tried Googling it and I have tried all of the stuff I found on Google but none of it has worked for me. I am trying to you the mkdir function but I keep getting an error that says: Warning: mkdir() [function.mkdir]: No such file or directory in /home/content/l/i/n/web/html/php/mkdir.php on line 6

     

    Here is my code:

     

    <?php
    
    //Create the directory for the user
    $directory = time() . rand(0, 49716) ;
    
    if (mkdir("/users/$directory", 0777)) {
    echo '<p>Directory was created successfully.</p>' ;
    } else {
    echo '<p>Directory was NOT created.</p>' ;
    }
    
    ?>
    

     

    I am placing the script called mkdir.php in the same folder as the users folder. The users folder has the permissions set to 0777. I am not sure why I keep getting this error because the users folder does exists. Any help is greatly appreciated.

  5. Can You Import an Excel File to a MySQL Database using phpMyAdmin? I am looking to buy this database that has the data of all Colleges and Universities in the US. The file is in Excel format. Can this be imported into phpMyAdmin?

     

    Here is the site where I am going to buy the database from if this is possible: http://www.data-lists.com/universities-colleges-database.html?gclid=CPGXkN6H6aECFeQc5wodBFPRIg

     

    You can download a sample of the database that has 10 entries. I have tried importing this into phpMyAdmin but this is the error I am getting:

     

    There is a chance that you may have

    found a bug in the SQL parser. Please

    examine your query closely, and check

    that the quotes are correct and not

    mis-matched. Other possible failure

    causes may be that you are uploading a

    file with binary outside of a quoted

    text area. You can also try your query

    on the MySQL command line interface.

    The MySQL server error output below,

    if there is any, may also help you in

    diagnosing the problem. If you still

    have problems or if the parser fails

    where the command line interface

    succeeds, please reduce your SQL query

    input to the single query that causes

    problems, and submit a bug report with

    the data chunk in the CUT section

    below:

    ----BEGIN CUT---- eNrtXAtsHMd5nt177R0FipQoiXqvICkiJd7xnnwJBnWiqFdIiubRjyQO5NVxSV51vGPuIYltVNNt

    CgS1azhSIre20sBNXLRp2jSOm9iIW8stYLcA3RZtmodjN3Zgp3FdtLWbokVg+/rPzO7evnkXyYna

    zhyHd/PvzP/N/PPP7Mw+vtGpqVNTQ+JITByJi2OjE0NiTIyLqYFkNBnKTMOR9lAoczuI95yYGRLL

    H8svSqWyXIrkc2cii/OLYiyWiiXEeDQ6EIa/+IAY6xuK9Q+lEh8W8/LCoLgnNL6UuXVsSExFopH+

     

    And then at the bottom of the error it says:

     

    #1064 - 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 'ÐÏࡱá' at line 1

     

    Any help is greatly appreciated.

  6. Hey everyone, I have a quick question. I want to build a web app for myself that will allow me to post stuff to Craigslist and retrieve postings from Craigslists. I am not doing this to spam Craigslist, I am just doing it to learn. My question is: Is this possible? If so, will knowing PHP be enough? Or will I also need to know how to use the cURL library? Thanks in advance for the help and advice.

  7. Hello everyone, I am working on a site similar to Craigslist where users can make postings and sell items in different cities. One difference between my site and Craigslist will be you will be able to search by zip code instead of having all of the cities listed on the page.

     

    I already have the ZIP Code database that has all of the city, state, latitude, longitude, and zip code info for each city. Okay, so to dive into what I need done and what I need help with:

     

    1.) Although I have the ZIP Code database, it is not setup perfectly for my use. (I downloaded it off of the internet for free from http://zips.sourceforge.net/)

    2.) I need help setting up my database structure (Ex: How many different tables should I use and how should I link them)

     

    I will be using PHP and MySQL.

     

    These our my thoughts so far on how the database can be setup: (I am not sure if this will work though.)

     

    Scenario:

     

    Someone goes to the homepage and it will tell them, "Please enter your ZIP Code.". If they enter "17241" for example, this ZIP Code is for a city named Newville located in Pennsylvania. The query would look like this with the current database setup:

     

    SELECT city FROM zip_codes WHERE zip = 17241;

     

    The result of the query would be "Newville".  The problem I see here now is when they want to post something in the Newville section of the site, I will have to have an entire table setup just for the Newville city postings. There are over 42,000 cities which means I would have to have over 42,000 tables (one for each city) so that would be insane to have to do it that way. One way I was thinking of doing it was to add a column to the ZIP Code database called "city_id" which would be a unique number assigned to each city. So for example, the city Newville would have a city_id of 83. So now if someone comes and post a listing in the city Newville I would only need one other table. That one other table would be setup like this:

     

    CREATE TABLE postings (
    posting_id INT NOT NULL AUTO_INCREMENT,
    for_sale LONGTEXT NULL,
    for_sale_date DATETIME NULL,
    for_sale_city_id INT NULL,
    jobs LONGTEXT NULL,
    jobs_date DATETIME NULL,
    jobs_city_id INT NULL,
    PRIMARY KEY(posting_id)
    );

     

    (The for_sale and job_ column names are categories of the types of postings users will be able to list under. There will be many more categories than just those two but this is just for example.)

     

    So now when when someone comes to the website and they are looking for something to buy and not sell, they can enter their ZIP Code, 17241, for example, and this is the query that will run:

     

    SELECT city, city_id FROM zip_codes WHERE zip = 17241; //Result: Newville 83
    

     

    (Please note that I will be using PHP to store the ZIP Code the user enters in SESSIONS and Cookies to remember them throughout the site)

     

    Now it will tell them, "Please choose your category.". If they choose the category "Items For Sale" then this is the query to run and sort the results:

     

    SELECT posting_id, for_sale, for_sale_date FROM postings WHERE for_sale_city_id = $_SESSION['zip_code'];

     

    Will this work?

     

    So now my question to everyone is will this work? I am pretty sure it will but I do not want to set this thing up and realize I overlooked something and have to start from all over from scratch. Any opinions and ideas are welcomed and I will listen to anyone who has some thoughts. I really appreciate the help in advance :D

  8. document.getElementById("placeholder");

    There isn't a line at all in yoru code that has the id 'placeholder'

    I'm no expert, but this is obviously going to be a problem. Not too sure where the ID is going to go though. I'm assuming its related to a place holder.

    I think the id should be in this line

    <img src="images/placeholder.jpg" title="Place Holder Image">

     

    so changing it to..

    <img src="images/placeholder.jpg" title="Place Holder Image" id="placeholder">

     

    Could be wrong..

     

    Hey thanks for the reply. I changed the line of code to add this:

     

    <img src="images/placeholder.jpg" title="Place Holder Image" id="placeholder">

     

    But it still did not work for me. Any other ideas?

     

  9. Hi everyone,

     

    I am new to JavaScript (only a couple of days of reading a book) and I am stuck on this code snippet. I have looked at it over and over again but cannot seem to figure out why it is not working. I am sure it is something really simple that I have just looked over but I really just need a fresh pair of eyes to look at this.

     

    The code is supposed to update a placeholder image on a page without the page having to reload. But when I am clicking on the link of an image, it is taking me to the link where the image is located instead of replacing the placeholder image. Here is my HTML code:

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Image Gallery</title>
    <script type="text/javascript" src="scripts/showPic.js"></script>
    </head>
    <body>
    
    <h1>Snapshots</h1>
    <ul>
    	<li>
    	<a href="images/cat.jpg" onclick="showPic(this); return false;" title="A Cat">Cat</a>
    	</li>
    	<li>
    	<a href="images/night.jpg" onclick="showPic(this); return false;" title="Night">Night</a>
    	</li>
    	<li>
    	<a href="images/coke.jpg" onclick="showPic(this); return false;" title="Coke">Coke</a>
    	</li>
    	<li>
    	<a href="images/sport.jpg" onclick="showPic(this); return false;" title="Sports">Sport</a>
    	</li>
    	<li>
    	<a href="images/mnms.png" onclick="showPic(this); return false;" title="MnM's">MnM's</a>
    	</li>
    	<li>
    	<a href="images/kid.jpg" onclick="showPic(this); return false;" title="A Kid">Kid</a>
    	</li>
    </ul>
    
    <br />
    
    <img src="images/placeholder.jpg" title="Place Holder Image">
    
    </body>
    </html>

     

    And here is the JavaScript function I am using to get this done:

     

    <script type="text/javascript">
    
    function showPic(whichpic) { 
    var source = whichpic.getAttribute("href"); 
    var placeholder = document.getElementById("placeholder"); 
    placeholder.setAttribute("src",source);
    }
    
    </script>

     

    Any help is greatly appreciated and thanks in advance for the help.

  10. Hey everyone, I need help with this simple script. Okay, I have files stored in a database that need to be downloaded. Here is the script I have so far:

     

    <?php
    
    //Connect to the database
    require_once('/mysql_connect.php') ;
    
    $query = "SELECT enrollment_form FROM students where student_id = {$_GET['student']}" ; 
    $result = mysqli_query($dbc, $query) or die('There was an error with the query. ' . mysqli_error($dbc)) ;
    $num = mysqli_num_rows($result) ;
    
    if ($num == 1) {
    
    //Query was successfull
    //Retrieve the file
    $data = mysql_result($result, 0, "enrollment_form") ;
    Header("Content-type: $data") ; 
    echo $data ;
    
    } else {
    
    //The record does not exists
    echo '<p>The record does not exists.</p>' ;
    
    }
    
    ?>

     

    The error I am getting is this:

     

    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/content/l/i/n//html/Payments/download_enrollment.php on line 14

     

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/l/i/n//html/Payments/download_enrollment.php:14) in /home/content/l/i/n//html/Payments/download_enrollment.php on line 15

     

    Any help on this is greatly appreciated.

     

    Why use mysql_result? Taken from the PHP manual:

    When working on large result sets, you should consider using one of the functions that fetch an entire row (specified below). As these functions return the contents of multiple cells in one function call, they're MUCH quicker than mysql_result().

     

    Try mysqli_fetch_row... or better yet mysqli_fetch_assoc

     

    while ($row = mysqli_fetch_row($result))
    {echo "Name: {$row['1']} Address {$row['2']}";
    }
    

     

    Hey thanks for the reply. Okay the code you gave me got rid of the errors but now instead of actually downloading the file, it trys to display it in the web browser. The file that is stored in the database is a PDF. Here is the new code:

     

    <?php
    
    //Connect to the database
    require_once('/mysql_connect.php') ;
    
    $query = "SELECT enrollment_form FROM students where student_id = {$_GET['student']}" ; 
    $result = mysqli_query($dbc, $query) or die('There was an error with the query. ' . mysqli_error($dbc)) ;
    $num = mysqli_num_rows($result) ;
    
    if ($num == 1) {
    
    //Query was successfull
    //Retrieve the file
    while ($row = mysqli_fetch_row($result)) {
    
    	echo $row[0] ;
    
    }
    
    } else {
    
    //The record does not exists
    echo '<p>The record does not exists.</p>' ;
    
    }
    
    ?>

     

    And here is part of the output that it is giving me in the web browser:

     

    %PDF-1.4 %°¸º• 1 0 obj<> endobj 5 0 obj<> endobj 6 0 obj<>stream xœ+ä234R0PÐ5P0·1’s¹ô=s \ò¹¹¸o• endstream endobj 9 0 obj 38 endobj 8 0 obj<>stream ÿØÿàJFIF°°ÿÛ„  (1#%(:3=<9387@H\N@DWE78PmQW_bghg>Mqypdx\egc//cB8BccccccccccccccccccccccccccccccccccccccccccccccccccÿÄ¢	 }!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùú	 w!1AQaq"2B‘¡±Á	#3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÀ3'ØÿÚ?ô ( € ( € (   € ( € ( € (   €€ ( € (  €€ (h € JZJ(h €€ (   € Z( € ((h(h € ( € JZ( € (     € (    €€ ((  € ( € ( € ( € (   € ( €€ ZJZ( € ( € J(  € ((h € ( € (   € ( € ( €€€ ( € ( € ( € ( € ( € ( € ( € ( €€€ ( € JZ( €€€ ( € ( € ((h €€ Z( € ( € ( € ( € JZ((  € (  €€ ((h €€€ ( €€€ ( € JZ( € ( € ( € ( € ( € ( € ( € ( € ( € JZ((h € ( € ( € ( € JZ(   € (   € ( € ( € ( €€€ ( € ( € ( € ( € ( € ( € ( €€ Z( € ( € ( € ( € ( € ( € ( € ( € ( € JZ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € JZ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € (   € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( €€€ ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( €€€ ( € ( € ( € ( € ( € ((h € ( € ( € ( € ( € ( € ((h € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € (   € ( € JZ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € (   € ( € ( € ( € ( € ( € ( € J(h € ( € ( € ( € ((h € ( € ( € ( € ( € ( € (   € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ((h(h   € ( € ((  €€ Z(  €€€€€€€€ ((h € JZ( € ( € (  € Z( €€ Z( € JZ(( €€ ((h €€€ (   € ( € ( € J(h € ( € J(h € ( € JZ((h € JZ( € ( € ((h(h(h €€€ ((h(  €€€ ( € ( € ( € ( €€ Z(   € ( € ( € ( € JZ( € ( € J(h € ( € ( € J(h €€€ ( ÐÐÐ@	@@P@ @@”´P@	@@P@P@	@@%-P@P@P@P@PP@@PPÐ@	@-P@	@@%-”´P@%-%-P@%-P@P@P@	@@P@	@@”´P@P@ @@P@P@P@P@”´P@”´P@P@P@PPÐ@PPÐ@P@P@P@P@P@P@P@P@P@P@P@P@ @@P@P@P@P@PPÐ@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@PPÐ@P@ @@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@PPÐ@P@P@P@”´P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@	@-P@P@P@P@P@P@P@P@P@P@PPÐ@P@P@P@P@P@P@P@P@P@P@%-P@P@P@%´P@P@P@P@%-P@P@PPÐ@P@P@P@P@P@P@P@P@P@P@P@P@%-P@P@P@P@	@@ @@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@”´P@P@P@P@PPÐ@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@PPÐ@”´””´P@@”´P@P@P@P@P@%´P@	@@	@@P@P@	@@%-P@	@-P@”PÐ@P@%PÐPÐ@P@”´P@P@”PÐ@P@P@P@P@P@P@PPÐ@P@PPÐ@”´P@ @@P@P@P@P@P@P@”´P@P@P@P@PP@@P@P@”PÐ@P@”´”´”´”´”´”PÐ8†·¸29F(ÕP@”PÐ@P@P@P@P@PPÐ@	@@P@%-P@	@@”PÐ@P@P@”´P@P@P@P@P@ @@P@P@P@%-P@P@P@PPÐ@P@P@P@%-”´PPÐPÐ@P@%-P@P@P@%-P@P@P@P@P@P@P@P@P@”´P@P@	@-P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@ @@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@%´P@PP@@P@P@P@P@P@P@P@P@P@P@PPÐ@P@”´P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@%´P@P@”PÐ@P@PPÐ@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@%-P@P@P@P@P@P@P@ @@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@%-P@P@P@P@P@P@P@P@	@@P@P@PPÐ@P@P@ @@P@P@P@P@P@P@P@P@P@P@%-P@P@P@P@	@@P@P@P@P@P@ @@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@P@	@@P@P@P@P@P@P@P@P@P@P@P@P@P@	@-%PÐ@”P@PÐ@%PÐPÐ@	@@%P@@	@´”PÐ@PP@@PPÐ@	@-P@PP@@%-%-P@P@	@-P@PPÐ@P@%-%-%-%-P@P@	@-”´P@P@P@P@P@P@P@P@P@ @@P@P@P@P@PPÐPÐ@P@P@PP@@P@P@	@@	@@	@@P@P@PPÐ@P@P@%PbohZ( € ( € ( € ( € ( € ( € ((  € (   € ( € ( € J(h € ( € (   € (  €€ J(h € ((  € ( € JZ( € ( € ( € ( € ( € ( € (   € (( €€ ((h € ( €€€ ( € JZ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( € ( €€€ ( € ( 

     

     

  11. Hey everyone, I need help with this simple script. Okay, I have files stored in a database that need to be downloaded. Here is the script I have so far:

     

    <?php
    
    //Connect to the database
    require_once(/mysql_connect.php') ;
    
    $query = "SELECT enrollment_form FROM students where student_id = {$_GET['student']}" ; 
    $result = mysqli_query($dbc, $query) or die('There was an error with the query. ' . mysqli_error($dbc)) ;
    $num = mysqli_num_rows($result) ;
    
    if ($num == 1) {
    
    //Query was successfull
    //Retrieve the file
    $data = mysql_result($result, 0, "enrollment_form") ;
    Header("Content-type: $data") ; 
    echo $data ;
    
    } else {
    
    //The record does not exists
    echo '<p>The record does not exists.</p>' ;
    
    }
    
    ?>

     

    The error I am getting is this:

     

    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/content/l/i/n//html/Payments/download_enrollment.php on line 14

     

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/l/i/n//html/Payments/download_enrollment.php:14) in /home/content/l/i/n//html/Payments/download_enrollment.php on line 15

     

    Any help on this is greatly appreciated.

     

  12. Hi everyone, I have a small problem. I am trying to get a list of names (the names of people are coming from my database) to show up in a option list html drop down. I have done this before plenty of times but have no idea why this is not working. I guess I just need a fresh pair of eyes to look at it. Any help is greatly appreciated. Thanks in advance.

     

    Oh yeah, by the way, I am not getting any errors. It is just that nothing shows up in the drop down list. I have typed the same query in the phpMyAdmin panel and it works perfectly so I know it is not the query itself.

     

    <?php
    
    //Check to see if the form has been submitted
    if (isset($_POST['submitted'])) {
    
    //Connect to the database
    require_once('/mysql_connect.php') ;
    
    //Create the query
    $query = "SELECT * FROM students WHERE student_id = {$_POST['student_name']}" ;
    $result = mysqli_query($dbc, $query) ;
    $num = mysqli_num_rows($result) ;
    
    if ($num >= 1) {
    
    	//Query was successfull
    	//Store all infomation in array
    	//Display the students information
    	$row = mysqli_fetch_array($result, MYSQLI_BOTH) ;
    	echo '<p>Student ID: <b>' . $row['student_id'] . '</b></p>' ;
    	echo '<p>Student Name: <b>' . $row['first_name'] . ' ' . $row['last_name'] . '</b></p>' ;
    	echo '<p>Student Phone #: <b>' . $row['phone'] . '</b></p>' ;
    	echo '<p>Student Address: <b>' . $row['address'] . '<br />' . $row['city'] . ', ' . $row['state'] . ' ' . $row['postal_code'] . '</b></p>' ;
    
    } else {
    
    	//There was an error with the query
    	echo '<p>There was an error with the query. Error # 1. The mysqli_error() is: ' . mysqli_error($dbc) ;
    
    }
    
    } else {
    
    //The form has not been submitted
    //Display the form
    
    echo '
    <fieldset><legend>Please select a student from the drop down list.</legend>
    <form action="home.php" method="post">
    <select name="student_name" size="1">' ;
    
    //Create the query
    $query = "SELECT student_id, first_name, last_name FROM students ORDER BY last_name" ;
    $result = mysqli_query($dbc, $query) ;
    $num = mysqli_num_rows($result) ;
    
    if ($num >= 1) {
    
    	//Query was successfull
    	//Fetch all of the results
    	while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
    
    		echo '<option value="' . $row['student_id'] . '">' . $row['last_name'] . ', ' . $row['first_name'] . '</option>' ;
    
    	}
    
    } else {
    
    	//There was an error with the query
    	echo '<p>There was an error with the query. Error # 2. The mysqli_error() is: ' . mysqli_error($dbc) ;
    
    }
    
    echo '
    </select>
    <p><input name="submit" type="submit" value="Submit"></p>
    <p><input name="submitted" type="hidden" value="true"></p>
        </form>' ;
    
    }
    
    ?>

  13. Hey everyone, I am having trouble with this script I am running. I am trying to store pdf's and image files in my MySQL database but I keep getting crazy output in my browser. So to break everything down, here is my database setup for just the file storage part:

     

    CREATE TABLE students (enrollment_from LONGBLOB NULL)

     

    Now, when I try to upload a file and store it in the database in the enrollment_from column, I get an error. Here is the code I am using to upload the file to the databse so it can be stored:

     

    //Start the SESSION
    session_start() ;
    
    if (!$_SESSION['loggedin']) {
    header('Location: http://blah/School/Home.html') ;
    exit() ;
    }
    
    /*If the user makes it this far, they have succesfully logged in.*/
    
    //Check to see if the form has been submitted
    if (isset($_POST['submitted'])) {
    
    //Set the default timezone
    date_default_timezone_set('US/Central') ;
    
    //Check to make sure there were no errors with the file upload
    if ($_FILES['file']['error'] == 0) {
    
    	if (!$fp = fopen($_FILES['file']['tmp_name'], 'r')) {
    		echo '<p>Could Not Open File.</p>' ;
                            exit() ;
    	}
    
    	if (!$file_content = fread($fp, $_FILES['file']['size'])) {
    		echo '<p>Could Not Read File.</p>' ;
                            exit() ;
    	}
    
    	//Connect to the database
    	require_once('blah/html/Payments/mysql_connect.php') ;
    
    	//Insert the uploaded content into the database
    	$query = "UPDATE students SET enrollment_form = '$file_content' WHERE student_id = " . $_SESSION['student_id'] . " LIMIT 1" ;
    	$result = mysqli_query($dbc, $query) ;
    	$num = mysqli_affected_rows($dbc) ;
    
    	if ($num == 1) {
    
    		//The query was successful
    		//Redirect the user to the upload 2 page where the 2nd document will be uploaded
    		header('Location: http://blah/Payments/upload2.php') ;
    		exit() ;
    
    	} else {
    
    		//There was an error with the query
    		echo '<p>There was an error in the query. Error # 1.</p>' ;
    
    	}
    
    } else {
    
    	//There was an error with the file upload
    	echo '<p>There was an error with the file upload. The error # is: ' . $_FILES['file']['error'] . '</p>' ;
    
    }
    
    } else {
    
    //The form has not been submitted
    //Display the form
    
    echo '
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Student Payment Center: Upload Enrollment Form</title>
    </head>' ;
    
    echo '
    <fieldset><legend>Please upload the students enrollment form into the form below.</legend>
    <form action="upload.php" method="post" enctype="multipart/form-data">
    <input name="MAX_FILE_SIZE" type="hidden" value="8388608">
    <p>Upload: <input name="file" type="file"></p>
    <input name="submit" type="submit" value="Upload">
    <input name="submitted" type="hidden" value="true">
    </form>' ;
    
    echo '<p>The student id is: ' . $_SESSION['student_id'] ;
    
    }
    
    ?>

     

    The error I am getting is this: There was an error in the query. Error # 1. It is my own error. It means there is an error with the query obviously but I am not sure what is wrong with the query. I have googled everything but have found no answers. Any help is greatly appreciated and Thanks in advance.

     

    --------------------------------------------------------------------------------------------------------------------------------------------

    EDIT

    I have been trying to upload every file type possible to see if anything will work, and the olny thing that will seem to work is a file with a .html extension. Why is?

  14. Hey thanks for your reply. I knew there was some thing vital I was missing. The following is the exact line I'm using

    if (ftp_get($resource, '/var/www/downloads/'.$files[$i], $files[$i], FTP_BINARY)){

     

    Every thing else is the same. When run, the script returns the same error for every file it tries to download. Theres about 30 of them so I won't copy past the whole thing but here's the first one.

    Warning: ftp_get(/var/www/downloads/fileIDX/pics-multi family-20100216.tar) [function.ftp-get]: failed to open stream: No such file or directory in /var/www/gwr/connect.php on line 30
    

     

    It's almost as if it needs the file to already be there before it can replace it. I don't understand what's going on here. Does any one have any suggestions. Thank you for your time.

     

    Check your permissions on the directory. Make it 0755 0r 0777

  15. that would eat up ur mysql space and also it is not such a good idea to store such large files in Mysql..

    store it some where and give a reference of that point in mysql.. i think that would do.

    I have to agree.

     

    I never store files in the mysql database, but instead store it in the filesystem and reference its location in the database.

     

    Thanks a lot for the replies. Okay, so for example, I have a website that adds 1 new video a day. My goal is to sort the videos by the newest first (Descending Order). Is this the way I would do it?:

     

    1.) Video is uploaded to the site

    2.) Insert the link, the date the video was uploaded, & size to the video in the database

     

    My question is how would I display the videos now? Is this correct so far?

  16. you could use a session to hold a test key then on completion increment the key so that when they go back to the test page the keys wont match up and you can respond accordingly

     

    That sounds like something I can definitely try. I currently have it setup like this:

     

    //Validate that the user is not accessing this page in error or coming back from completion page
    $r = $_SERVER['HTTP_REFERER'] ;
    if ($r != 'http://sitename.com/Tests/Tests.php') {
    header('Location: http://sitename.com/Home/Home.html') ;
    exit() ;
    }

     

    This code is at the beginning of my script and it validates that the user is coming from the correct page. But this code does not seem to run when the user clicks the back button. So would a session solve this or would it cause the same problem? Thanks a lot for the help.

     

  17. Hi, I have a small problem with a site I am creating. I have made an online school site for a client that allows a student to take their test online and once they are done taking the "Math" test for example, it will show them the numbers they have missed and the numbers they have correctly answered. My concern is that if they click the back button, the test is still available and the radio buttons are still selected from the first time they took the test. Is there anyway for me to give them an error when they try to access the page again? Something like, "This page has expired". Thanks a lot in advance for the help.

  18. If its your own server just edit the httpd.conf file and add the extensions to the addType line, save the file and restart apache and you will not have to use an .htaccess file for each site you do.

     

     

    HTH

    Teamtomic

     

    Hey thanks a lot for the replies. Ok I have tried everything you all have told me but when I upload the .htacces file to the www directory (the directory that is visible to the web), it does the weirdest thing. When i go to www.mysite.com/index.html it will download the index.html file. When i delete the .htaccess file, everything works perfectly again. Any one know why it is doing this?

     

    Here is my .htaccess file components:

     

    RemoveHandler .html .htm

    AddType application/x-httpd-php .php .htm .html .phtml

  19. RemoveHandler .html .htm

    AddType application/x-httpd-php .php .htm .html .phtml

     

    ok awesome. And would I just put that in the directory where I upload my files tithe server? And does that work for the whole server or just the directory that it is in? Also, do I have to restart my server? Thanks again

  20. Hi, I am tryng to configure my server to parse HTML files as php. I just don't know where to put the .htaccess file on my server. I don't have root access on my server since I am on a shared hosting plan with GoDaddy. Any help in the right direction would be great. Thanks a lot in advance for the help.

     

    So would I just create an .htaccess file and add this one line?

     

    AddType application/x-httpd-php .html

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.