Jump to content

ddevitt

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Posts posted by ddevitt

  1. Hello everyone,

    I'm having a problem uploading a image file to the server and adding the filename to my MySQL database. I do not get any error messages, but in the database field the file name and path gets inserted. Example C:\images\test.jpg and still no uploaded file. my code is below. thanks in advance.
    [code]
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }



    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

    $var = $_FILES['propertyImg'] ['name'];
    move_uploaded_file ($_FILES['propertyImg'] ['tmp_name'],
    "../propimages/{$_FILES['propertyImg'] ['name']}");

    $insertSQL = sprintf("INSERT INTO offerings (pname, address, city, `state`, sqft, clearHeight, typeConstruction, additionalInfo, propertyImg, confientiality, memo, otherTitle1, otherFile1, otherTitle2, otherFile2, otherTitle3, otherFile3, otherTitle4, otherFile4, `user`, pass, displayOffering, buyer, seller, saleDate, mdesc, transSum, displayCaseStudy) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['pName'], "text"),
    GetSQLValueString($_POST['address'], "text"),
    GetSQLValueString($_POST['city'], "text"),
    GetSQLValueString($_POST['state'], "text"),
    GetSQLValueString($_POST['sqft'], "text"),
    GetSQLValueString($_POST['clearHeight'], "text"),
    GetSQLValueString($_POST['typeConstruction'], "text"),
    GetSQLValueString($_POST['additionalInfo'], "text"),
    GetSQLValueString($_POST['propertyImg'], "text"),
    GetSQLValueString($_POST['confientiality'], "text"),
    GetSQLValueString($_POST['memo'], "text"),
    GetSQLValueString($_POST['otherTitle1'], "text"),
    GetSQLValueString($_POST['otherFile1'], "text"),
    GetSQLValueString($_POST['otherTitle2'], "text"),
    GetSQLValueString($_POST['otherFile2'], "text"),
    GetSQLValueString($_POST['otherTitle3'], "text"),
    GetSQLValueString($_POST['otherFile3'], "text"),
    GetSQLValueString($_POST['otherTitle4'], "text"),
    GetSQLValueString($_POST['otherFile4'], "text"),
    GetSQLValueString($_POST['user'], "text"),
    GetSQLValueString($_POST['pass'], "text"),
    GetSQLValueString(isset($_POST['displayOffering']) ? "true" : "", "defined","1","0"),
    GetSQLValueString($_POST['buyer'], "text"),
    GetSQLValueString($_POST['seller'], "text"),
    GetSQLValueString($_POST['saleDate'], "date"),
    GetSQLValueString($_POST['mdesc'], "text"),
    GetSQLValueString($_POST['transSum'], "text"),
    GetSQLValueString(isset($_POST['displayCaseStudy']) ? "true" : "", "defined","1","0"));

    mysql_select_db($database_converse, $converse);
    $Result1 = mysql_query($insertSQL, $converse) or die(mysql_error());

    $insertGoTo = "offeringsStart.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }[/code]
  2. Thanks for all of the help so far. I attempted to alter the query and let MYSQL handle it, but I am getting the following error.

    Notice: Undefined index: mdate in c:\Inetpub\wwwroot\dave\PHPDate.php on line 20

    here is my code:

    [code]<?php
    mysql_select_db($database_daveConn, $daveConn);
    $query_Recordset1 = "SELECT title, DATE_FORMAT(mdate, '%m/%e/%Y') FROM news";
    $Recordset1 = mysql_query($query_Recordset1, $daveConn) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>

    <?php do { ?>
      <tr>
        <td><?php echo $row_Recordset1['mdate']; ?></td>
        <td><?php echo $row_Recordset1['title']; ?></td>
      </tr>
      <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>[/code]

    I figured it out. I forgot the "AS" portion of the SQL statment.

    Thanks to everyone who helped out!!!
  3. Hi everyone. I'm new here and to PHP. My problem is I'm pulling a date out of a MYSQL database and I want to format it like mm/dd/yyyy. Is there a PHP function that can do this? I'm aware of the date() function but I can't seem to make that work.

    Any help is greatly appreciated.

    Thanks
    Dave
×
×
  • 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.