SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Code problems

  1. #1
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Code problems

    Using Dreamweaver, i am tryin to append my recordset depending on the username but i am getting the following error: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 'LIKE '%user1%'' at line 1
    What i want to be able to do is if there is a user logged in to display their info.

    I only got the error when i added the following line of code that is bold. Can someone help please

    PHP Code:
    <?php require_once('Connections/PropertyConnect.php'); ?>
    <?php
    if (!isset($_SESSION)) {
    session_start();

    }

    if (!
    function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
    if (
    PHP_VERSION 6) {
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }

    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
    }
    }

    mysql_select_db($database_PropertyConnect$PropertyConnect);
    $query_rsTestSim "SELECT information.custId, information.Username FROM information";
    if (isset(
    $_POST['InfoID'])) {
    $Info mysql_real_escape_string($_POST['InfoID']);
    $query_rsTestSim.= "WHERE custId LIKE '%$Info%'";
    }
    else if(isset(
    $_SESSION['MM_Username'])){
    $logUser mysql_real_escape_string($_SESSION['MM_Username']);
    $query_rsTestSim.= "WHERE Username LIKE '%$logUser%'";

    }
    $rsTestSim mysql_query($query_rsTestSim$PropertyConnect) or die(mysql_error());
    $row_rsTestSim mysql_fetch_assoc($rsTestSim);
    $totalRows_rsTestSim mysql_num_rows($rsTestSim);

    echo 
    $query_rsTestSim;
    echo 
    $totalRows_rsTestSim;

    ?>

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,204
    Mentioned
    106 Post(s)
    Tagged
    1 Thread(s)
    It's because there's no space before the word WHERE. Either put a space between the " and the WHERE (you've got it in two places in your code....) or between the word information and the " at the end.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  3. #3
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much that did the job.


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
  •