Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts

    script to show images in my message :P

    hey guys...im getting 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 'as `ext` FROM tagboard as t,users,photos WHERE t.account = 'Admin' AND t.nick=us' at line 1
    PHP Code:
        $sql "SELECT t.*,user_images.ext as ext,users.ID as pid as `ext` FROM $tablname as t,users,photos WHERE t.account = '$user2' AND t.nick=users.ID AND users.ID = user_images.user_id ORDER BY t.id DESC LIMIT $howmany";
    $result mysql_db_query($database,$sql,$connection) or die(mysql_error());
    while(
    $row mysql_fetch_assoc($result)){
        
    $nick     $row["nick"]; 
        
    $url      $row["url"];
        
    $message  $row["message"];
        
    $datetime $row["datetime"];
        
    $sentondate("M jS, Y \a\\t h:i A T"$datetime);
        
    $pid $row['pid'];
        
    $ext $row['ext'];
        
    //echo out as required
         

    not sure where... this is 1st time im using the combind querying... mine used to look like this

    PHP Code:
    <?php $SQL "SELECT * FROM $tablname WHERE account = '$user2' ORDER BY id DESC LIMIT $howmany";

        
    $results mysql_db_query($database"$SQL"$connection);
        if (!
    $results)
          return (
    "ERROR: " mysql_error() . "\n$SQL\n");
        
        while (
    $row mysql_fetch_array($results))
          { 
            
    $nick     $row["nick"]; 
            
    $url      $row["url"];
            
    $message  $row["message"];
            
    $datetime $row["datetime"];
            
    $sentondate("M jS, Y \a\\t h:i A T"$datetime);


            
    /* Add Emoticons to the user's message */
           
    if ($emoticon == 1)
              
    $msg emoticon($message);

            
    /* Some people don't have web sites, so we check to see if they put a URL in the database */
            
    if ($url=="" or $url=="http://"/* If they didn't then we just display the nick and the message */
              
    $nick "$nick";
            else 
    /* If they did, then we link it!! */
              
    $nick "<a href=\"$url\" target=\"_blank\">$nick</a>";
              
              
    $query "SELECT * FROM users WHERE Username = '$nick' LIMIT 1"
    if (
    $result mysql_query($query)or die("Error running query:".mysql_error())){
        if (
    mysql_num_rows($result)) {
            
    $array mysql_fetch_assoc($result);
            
    $pid $array['ID'];
               
    $sql "SELECT `ext` FROM `user_images` WHERE `user_id`='$pid' LIMIT 1";?>
      <table width="100%" cellpadding="0" cellspacing="0">
      <tr>
        <td width="1%" rowspan="3" align="left" valign="top"><?php  $q mysql_query($sql) or die("Error running query:".mysql_error());
                                     if(
    $q && mysql_num_rows($q) > 0)  {
                                    
    $row mysql_fetch_array($q);                                
                                    if(!empty(
    $row)) {
                                    echo 
    "<img src='http://www.website.com/members/images/mini/"$pid "." $row['ext']  . "'";
                                            }
                                            else {
                                        echo 
    'no image';
                                                    }
                                                                                                                                                }
                                                
    ?>
    im i doing it right?
    Last edited by runnerjp; 05-17-2008 at 07:18 PM.

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Code:
    $sql = "SELECT t.*,user_images.ext as ext,users.ID as pid as `ext`
    You can't assign two column names to the alias.

  • #3
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    ok i bailed on that idea i was getting to confused at what coloums whent wherre ect lol gonna go for long widned version

    PHP Code:
    <?
    session_start
    ();
    require_once 
    '../../settings.php';
    require (
    "required.php");

    echo 
    "<!-- $scriptname v$version Start -->\n\n";
    echo 
    "<HTML>\n";
    echo 
    "  <HEAD>\n";
    echo 
    "    <LINK rel=\"stylesheet\" type=\"text/css\" href=\"shoutbox/tagboard.css\">\n";
    echo 
    "  </HEAD>\n";
    echo 
    "  <BODY topmargin=\"2\" leftmargin=\"2\" bottommargin=\"2\" rightmargin=\"2\">\n";
    $user2 =  $_GET['username'];
    if (
    $usemysql == 1)
      {
        
    /* Load the tagboard, the X number of most recent posts */
        
    if ($order == "0")
        
        
    $SQL "SELECT * FROM $tablname WHERE account = '$user2' ORDER BY id DESC LIMIT $howmany";

        
    $results mysql_db_query($database"$SQL"$connection);
        if (!
    $results)
          return (
    "ERROR: " mysql_error() . "\n$SQL\n");

        


        while (
    $row mysql_fetch_array($results))
          { 
            
    $nick     $row["nick"]; 
            
    $url      $row["url"];
            
    $message  $row["message"];
            
    $datetime $row["datetime"];
            
    $sentondate("M jS, Y \a\\t h:i A T"$datetime);


            
    /* Add Emoticons to the user's message */
           
    if ($emoticon == 1)
              
    $msg emoticon($message);

            
    /* Some people don't have web sites, so we check to see if they put a URL in the database */
            
    if ($url=="" or $url=="http://"/* If they didn't then we just display the nick and the message */
              
    $nick "$nick";
            else 
    /* If they did, then we link it!! */
              
    $nick "<a href=\"$url\" target=\"_blank\">$nick</a>";
              }
              
    $query "SELECT * FROM users WHERE Username = '$nick' LIMIT 1"
    if (
    $result mysql_query($query)or die("Error running query:".mysql_error())){
        if (
    mysql_num_rows($result)) {
            
    $array mysql_fetch_assoc($result);
            
    $pid $array['ID'];}
               
    $sql "SELECT `ext` FROM `user_images` WHERE `user_id`='$pid' LIMIT 1";?>
      <table width="100%" cellpadding="0" cellspacing="0">
      <tr>
        <td width="1%" rowspan="3" align="left" valign="top"><?php  $q mysql_query($sql) or die("Error running query:".mysql_error());
                                     if(
    $q && mysql_num_rows($q) > 0)  {
                                    
    $row mysql_fetch_array($q);                                
                                    if(!empty(
    $row)) {
                                    echo 
    "<img src='http://www.runningprofiles.com/members/images/mini/"$pid "." $row['ext']  . "'";
                                            }
                                            else {
                                        echo 
    'no image';
                                                    }

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

        

                                                }
                                                
    ?> </td>
        <td width="99%" bgcolor="#e4ebeb"><?php echo $nick;?> wrote</td>
      </tr>
      <tr>
        <td bgcolor="#e4ebeb">at <? echo $senton;?></td>
      </tr>
      <tr>
        <td><? echo $msg;?></td>
      </tr>
      
    </table>
      <BR>


            
            <?
          
    }

        

        

        

        


          
    /* Like always, we close the connection to the database */
          
    mysql_close($connection);
      }
    else
      {
        
    $i 0;
        
    $file_lines file($flatfile);

        foreach(
    $file_lines as $line)
          {
            if (
    $i <= $howmany)
              {
                
    $delim    strpos($line"%%");
                
    $ts_delim strpos($line"@@");
                
    $ip_delim strpos($line"##");

                
    $nick substr($line0$delim);
                
    $message substr($line$delim 2$ts_delim $delim 2);
                
    $ts substr($line$ts_delim 2$ip_delim $ts_delim 2);
      
                if (
    $timestamping == 1)
                  echo 
    "    <B>$nick ($ts)$spacer</B> ";
                else 
                  echo 
    "    <B>$nick$spacer</B> ";

                if (
    $emoticon == 1)
                  echo (
    emoticon($message)); 
              
                  

                echo 
    "<BR>\n";

                
    $i++;
              }
          }
      }



    function 
    emoticon($msg)
      {
        
    $msg str_replace("o:-)""<IMG src=\"http://www.r.com/members/shoutbox/images/angel.gif\">"$msg);
       
        return 
    $msg;
      }

    ?>
    the problem is my images are not being shown :S i think i have put a } in the wrong place but im not sure...

  • #4
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    PHP Code:
    <?php  $sql "SELECT t.*,user_images.ext as ext,users.ID as pid FROM $tablname as t,users,user_images WHERE t.account = '$user2' AND t.nick=nick AND users.ID = user_images.user_id ORDER BY t.id DESC LIMIT 10";
    $result mysql_db_query($database,$sql,$connection) or die(mysql_error().'<br />Query was:'.$sql);
    while(
    $row mysql_fetch_assoc($result)){
        
    $nick     $row["nick"]; 
        
    $url      $row["url"];
        
    $message  $row["message"];
        
    $datetime $row["datetime"];
        
    $sentondate("M jS, Y \a\\t h:i A T"$datetime);
        
    $id $row['pid'];
        
    $ext $row['ext'];
        
    //echo out as required
       
    ?>

    where it says ORDER BY t.id DESC LIMIT 10 well for some reason its only displaying 1 message rather then 10 :S

    would look like this <?php $SQL = "SELECT * FROM $tablname WHERE account = '$user2' ORDER BY id DESC LIMIT 10";?>




    also... the image is not displaying for the right person... what i need it to be is that $nick = username in the table users... so what parts do i need to chnage for that..iv had ago but keep getting errors
    Last edited by runnerjp; 05-17-2008 at 10:55 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •