Jump to content

Moron

Members
  • Posts

    369
  • Joined

  • Last visited

Posts posted by Moron

  1. where BoardName='Youth Advisory Board' and Active = '-1'
    

    because, I presume that actually returns a row. What you need to do is take the query that isn't working and run it directly against the DB. If it returns 0 rows, you have found your problem. If it returns at least 1 row then come back and we can look at it more.  :)

     

    Cheers.

     

    The above works fine. It's selecting all members who are on that board and who are checked as Active. It just doesn't work when I put in more than two perimeters.

     

  2. Here's the main snippet:

     

    $RESULTMEMBER=mssql_query("select * from MemberInfo MI 
    
    where BoardName='Youth Advisory Board' and RepresentativeFor = 'City Staff Representative'  
    
    order by MI.[LName]");
    
    $RESULTYAB=mssql_fetch_assoc($RESULTMEMBER);
    $RESULTMEMBERCOUNT=mssql_num_rows($RESULTMEMBER);
    
    mssql_data_seek($RESULTMEMBER,0);
    
    while ($RESULTYAB = mssql_fetch_assoc($RESULTMEMBER))   {
    
    (Do Stuff Here)

     

    So why can't I add the "and Active = '-1'" part into the query here? It works fine here:

     

    $RESULTMEMBER=mssql_query("select * from MemberInfo MI where BoardName='Youth Advisory Board' and Active = '-1' order by MI.[LName]");
    $RESULTYAB=mssql_fetch_assoc($RESULTMEMBER);
    $RESULTMEMBERCOUNT=mssql_num_rows($RESULTMEMBER);

  3. $RESULTMEMBER=mssql_query("select * from MemberInfo MI 
    where BoardName='Youth Advisory Board' and RepresentativeFor = 'City Staff Representative'
    order by MI.[LName]");

     

    What is:

    MemberInfo MI

    Why is there a space in therE?

     

    What is:

    MI.[LName]

    Brackets for what?

     

    MI is the abbreviation for MemberInfo. The space is normal.

     

    The bottom line seems to be that I can only use two stipulations in the WHERE clause, but not three. That's why I'm wondering if my syntax is just wrong. I've tried every bracketing combination I can think of.

     

  4.  

    What does this give you? And I mean, copy/paste the entire message. Entire query and error message.

     

    Here's the entire query:

     

    $RESULTMEMBER=mssql_query("select * from MemberInfo MI 
    
    where BoardName='Youth Advisory Board' and RepresentativeFor = 'City Staff Representative'
    
    order by MI.[LName]");

     

    It works fine.

     

    But if I make it:

     

    $RESULTMEMBER=mssql_query("select * from MemberInfo MI 
    
    where BoardName='Youth Advisory Board' and RepresentativeFor = 'City Staff Representative' and Active = '-1' 
    
    order by MI.[LName]");

     

    (adding the Active part)

     

    ..it crashes. The "Active" part works fine elsewhere.

     

    The error this causes is:

     

    Warning: mssql_data_seek() [function.mssql-data-seek]: Bad row offset in C:\Wamp\www\boards\YAB\YAB.php on line 117

     

     

     

  5. Okay, this query works fine:

     

    where BoardName='Youth Advisory Board' and RepresentativeFor = 'City Staff Representative'

     

    But if I add another element:

     

    where BoardName='Youth Advisory Board' and RepresentativeFor = 'City Staff Representative' and Active = '-1'

     

    ...it crashes.

     

    The "Active = '-1'" part works fine in other queries.

     

    Is my syntax wrong when I go to three criterias in the WHERE statement?

     

  6. PHP is a web server language extension. Each web server has a different PHP dll/executable, a different environment, and likely a different location for looking for a php.ini file.

     

    To get the quickest solution, post whatever symptoms you are getting that are telling you that it is not working.

     

    I've now eliminated Apache as the problem. If I hit a direct web path to the files, everything runs like a champ. I think it might be a weird bug in Joomla! itself.

     

     

  7. If they always fail, it is likely due to a configuration problem or wrong database details.

     

    Start by checking your web server log file for errors.

     

    You would need to post your code if you what help with what it might or might not be doing, such as no error checking, no error reporting, and no error recovery logic.

     

    I see several errors in the Apache log that refer to not being able to map certain images. I can fix that by, if nothing else, using straight HTML code for the images instead of embedding the HTML code inside PHP.

     

    The website is currently on IIS. We're moving it to Apache on the same server using a Joomla! interface.

     

    PHP runs fine on Apache as long as there isn't a database connection.

     

    So why would the same connection statement fail if running on the same server?

     

  8. Okay, let's say that my database result produces the number....

     

    423487.00

     

    I can easily use substr() to give me "423," a comma, then "487.00" to produce...

     

    423,487.00

     

    But.... if the thousands position is under 100, like say 23,487.00, then it adds a number from somewhere.

     

    How do I directly plug the comma in there, putting it 6 positions from the right, regardless of what is before it?

     

  9. There are a bazillion javascript dropdown menus out there and I'm going to be using one. My question is, how do I use a variable, selected by a Javascript dropdown, in a query?

     

    In specific, this will be for employee paystubs online. They'll select their pay period ending date from the menu, then the query will be ran using that date in the WHERE statement.

     

    Thanks!

     

     

  10. If it doesn't work, I would paste the whole query into the MySQL forums here for someone to look at.

     

    Sorry I let this go for a while. I was off for a week.

     

    Anyway, here's the WHERE portion:

     

    WHERE ((M2.[EMPNO] = '".$_POST['empcode']."' and 
    M2.[MSSNO] = '".$_POST['password']."') or (M2.[MSSNO] = '".$_SESSION['password']."' and M2.[EMPNO] = '".$_SESSION['empcode']."'))
    

     

    I want to only use the last four digits of M2.[MSSNO] by truncating it with substr().

     

     

  11. Their $_POST['password'] is 4 digits right?

     

    SUBSTRING (M2.[MSSNO]-4) = '".$_POST['password']."'

     

    Thanks, but this crashes everything.

     

    The entire WHERE statement is:

     

    WHERE ((M2.[EMPNO] = '".$_POST['empcode']."' and 
    M2.[MSSNO] = '".$_POST['password']."') or (M2.[MSSNO] = '".$_SESSION['password']."' and M2.[EMPNO] = '".$_SESSION['empcode']."'))

     

     

     

  12. I'm already using the substr() function (see above), but I'm having a very hard time using it in the query. Maybe it's a syntax problem.

     

    Basically, I want to say WHERE

     

    substr(M2.[MSSNO], -4)
    

     

    ...is equal to

     

    $_SESSION['password']
    

     

    Have I missed something here or is the problem that I'm using the wrong syntax in the query?

     

  13. I'm writing an "employee information" application that allows employees to track accrued leave, benefits, etc.... I had been using their employee number as the username and SSN as the password. I've just been told that they want me to use just the last four of the SSN for security purposes.

     

    The database field has the entire SSN. I can use the following line...

     

    $lastfour = substr($_SESSION['password'], -4); // returns last four of password
    

     

    ... to truncate it to just the last four digits.

     

    But my question is, how do I incorporate $lastfour into the query? The WHERE part of the query is:

     

    WHERE ((M2.[EMPNO] = '".$_POST['empcode']."' and 
    M2.[MSSNO] = '".$_POST['password']."') or (M2.[MSSNO] = '".$_SESSION['password']."' and M2.[EMPNO] = '".$_SESSION['empcode']."'))

     

    Since the $lastcode function uses the SSN as pulled from M2.[MSSNO], I'm assuming that it doesn't "exist" until after the query is ran. Or am I wrong about that?

     

    Cliffnotes:

     

    Instead of using the entire SSN from the database, I want to use the last four digits as determined by the $lastfour function.

     

     

     

  14. This line:

     

    echo "<img src=\"photos/$department/$filename\" width=120 height=160 border=5 bordercolor=blue>";

     

    ....produces no image and the properties say:

     

    http://server/mainfolder/photos/Computer%20Services%20%20%20%20%20%20%20%20%20%

     

    Am I correct in assuming that the multiple "%20" entries at the end represent the remainder of the field?

     

    If so, how do I make it cut off after the last actual character? (I want the legitimate %20 spaces intact)

  15. //assume DB conn is made
    $id = $_GET['id'];
    if(!is_numeric($id)) exit;
    $q = mysql_query("SELECT image FROM employees WHERE id = '{$id}'");
    if($r = mysql_fetch_assoc) {
         header("Content-type: image/jpeg");
         echo $r['image'];
    }
    

     

     

    That does off course assume that your image is stored in a blob field as plain binary, and that the image was inserted correctly.

     

    The storage works like this: I open up an Access database (yeah, yeah, I know) with an MS SQL back end. I click on the image block and paste the image into it (after resizing, etc....), then save. Then, of course, the php code queries straight from the SQL.

     

    In your code posted above, would I need a connection statement on that page or is the connection statement on the page I call it from sufficient? And speaking of which, how do I call it? With an <IMG> tag?

     

  16. Here's the thing, guys, and maybe I didn't explain myself very well. Right now, I create a link to the employee's picture by using the first and last name from the database. For example, an employee named Fred Smith will have a link constructed that points to FredSmith.jpg and his picture will show. That's no problem.

     

    But the reason I had to resort to this method is because I couldn't pull the image straight out of the database and have it show properly. When it shows at all, it only shows ASCII garbage. I don't want to have to maintain a folder full of employee images and constantly make sure that each file name is exactly FirstnameLastname.jpg and that it matches the database exactly. Not only that, but when I take someone's picture and he tells me that his name is Tom Jones, I don't want to have to browse to his picture and rename it ThomasJones.jpg a week later when he tells me that it isn't showing.

     

    See what I mean?

     

    I want to know the proper, working method, once and for all, to pull a binary image from the database and have it show as a picture.

     

    Any help will be greatly appreciated.

     

    EDIT: In case anyone is wondering, yes, I have the GD Library installed and working properly.

     

  17. I never got this resolved some months ago, so I switched to using the First name and Last name from a database to construct a link to the images.

     

    This presents two problems (so far):

     

    1. I have to keep these images in a folder and make sure that the file names match the first and last names from the database.

     

    2. We have two employees with the exact same first and last names. No kidding.

     

    I've researched this a few times and it appears that I need two components for this to happen: one php file, like "image.php" or whatever that displays the image, and an <IMG> tag to point to this image.php file.

     

    But I still can't get anything but a red 'x' so far.

     

    Anyone know the correct way of doing this?

     

     

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