Skip to main content
edited tags
Link
Yuri Laguardia
  • 2.6k
  • 1
  • 10
  • 17
updating with code and links to previous questions
Source Link
borker
  • 301
  • 1
  • 8

PSET6: queryPHP parser + cat2.html no longer in directory + not loading multiple errorsworking + different files from Check50?

3 hopefully 'quick' issues if someone could help? [Edit: full code now here for reference - http://pastebin.com/d1jTs1jV]

1) My query parser for php isn't working. I thought believe I've done it right, so I'd appreciate some help here. CS50 check one passed fine, but check 2 gives me errors

Requesting hello.php? returns 200, text/html, and correct output \ expected output, not an exit code of 0

:( Requesting hello.php?name=Alice returns 200, text/html, and correct output \ expected output, not an exit code of 0

Here's the code for my parse (can remove once answered)

if (strchr(line, '?') == NULL)
// look for a query; if there is none - set it equal to null terminator as spec'ed
{
    *query = '\0';
    return true; 

}
char* query_ptr = strchr(line, '?');
// otherwise, you should have ? and a valid pointer to it with strchr
if (query_ptr == NULL)
{
// make sure you get a valid pointer;
    error(501);
    return false;
    
}

else if (*(query_ptr + 1) == ' ')
// check if there is nothing after the question mark - if so, again query is ""
{
    *query = '\0';
}
else
// otherwise, start from 1 after the question mark and copy the lowercase query into the index and null terminate
{
    query_ptr++;
    int query_idx = 0;
    while(*(query_ptr + query_idx) != ' ')
    {
        *(query + query_idx) = tolower(*(query_ptr + query_idx));
        query_idx++;
    }
    *(query + query_idx + 1) = '\0';
    return true;
}

2. cat2.html + cat3.html are no longer in the directories I think I saw someone say to email someone with the code to check, is that the case?

**3. I can't load 2 files ** Not sure what's going on here - I can load cat.html and cat.jpg successfully separately.

Thanks for any help!

PSET6: query parser + cat2.html no longer in directory + not loading multiple errors

3 hopefully 'quick' issues if someone could help?

1) My query parser for php isn't working. I thought believe I've done it right, so I'd appreciate some help here. CS50 check one passed fine, but check 2 gives me errors

Requesting hello.php? returns 200, text/html, and correct output \ expected output, not an exit code of 0

:( Requesting hello.php?name=Alice returns 200, text/html, and correct output \ expected output, not an exit code of 0

Here's the code for my parse (can remove once answered)

if (strchr(line, '?') == NULL)
// look for a query; if there is none - set it equal to null terminator as spec'ed
{
    *query = '\0';
    return true; 

}
char* query_ptr = strchr(line, '?');
// otherwise, you should have ? and a valid pointer to it with strchr
if (query_ptr == NULL)
{
// make sure you get a valid pointer;
    error(501);
    return false;
    
}

else if (*(query_ptr + 1) == ' ')
// check if there is nothing after the question mark - if so, again query is ""
{
    *query = '\0';
}
else
// otherwise, start from 1 after the question mark and copy the lowercase query into the index and null terminate
{
    query_ptr++;
    int query_idx = 0;
    while(*(query_ptr + query_idx) != ' ')
    {
        *(query + query_idx) = tolower(*(query_ptr + query_idx));
        query_idx++;
    }
    *(query + query_idx + 1) = '\0';
    return true;
}

2. cat2.html + cat3.html are no longer in the directories I think I saw someone say to email someone with the code to check, is that the case?

**3. I can't load 2 files ** Not sure what's going on here - I can load cat.html and cat.jpg successfully separately.

Thanks for any help!

PSET6: PHP parser not working + different files from Check50?

3 hopefully 'quick' issues if someone could help? [Edit: full code now here for reference - http://pastebin.com/d1jTs1jV]

1) My query parser for php isn't working. I thought believe I've done it right, so I'd appreciate some help here. CS50 check one passed fine, but check 2 gives me errors

Requesting hello.php? returns 200, text/html, and correct output \ expected output, not an exit code of 0

:( Requesting hello.php?name=Alice returns 200, text/html, and correct output \ expected output, not an exit code of 0

Here's the code for my parse (can remove once answered)

if (strchr(line, '?') == NULL)
// look for a query; if there is none - set it equal to null terminator as spec'ed
{
    *query = '\0';
    return true; 

}
char* query_ptr = strchr(line, '?');
// otherwise, you should have ? and a valid pointer to it with strchr
if (query_ptr == NULL)
{
// make sure you get a valid pointer;
    error(501);
    return false;
    
}

else if (*(query_ptr + 1) == ' ')
// check if there is nothing after the question mark - if so, again query is ""
{
    *query = '\0';
}
else
// otherwise, start from 1 after the question mark and copy the lowercase query into the index and null terminate
{
    query_ptr++;
    int query_idx = 0;
    while(*(query_ptr + query_idx) != ' ')
    {
        *(query + query_idx) = tolower(*(query_ptr + query_idx));
        query_idx++;
    }
    *(query + query_idx + 1) = '\0';
    return true;
}

2. cat2.html + cat3.html are no longer in the directories I think I saw someone say to email someone with the code to check, is that the case?

**3. I can't load 2 files ** Not sure what's going on here - I can load cat.html and cat.jpg successfully separately.

Thanks for any help!

added 4 characters in body
Source Link
borker
  • 301
  • 1
  • 8

3 hopefully 'quick' issues if someone could help?

1) My query parser for php isn't working. I thought believe I've done it right, so I'd appreciate some help here. CS50 check one passed fine, but check 2 gives me errors

Requesting hello.php? returns 200, text/html, and correct output \ expected output, not an exit code of 0

:( Requesting hello.php?name=Alice returns 200, text/html, and correct output \ expected output, not an exit code of 0

Here's the code for my parse (can remove once answered)

if (strchr(line, '?') == NULL)
// look for a query; if there is none - set it equal to null terminator as spec'ed
{
    *query = '\0';
    return true; 

}
char* query_ptr = strchr(line, '?');
// otherwise, you should have ? and a valid pointer to it with strchr
if (query_ptr == NULL)
{
// make sure you get a valid pointer;
    error(501);
    return false;
    
}

else if (*query_ptr*(query_ptr + 1) == ' ')
// check if there is nothing after the question mark - if so, again query is ""
{
    *query = '\0';
}
else
// otherwise, start from 1 after the question mark and copy the lowercase query into the index and null terminate
{
    query_ptr++;
    int query_idx = 0;
    while(*query_ptr*(query_ptr + query_idx) != ' ')
    {
        *(query + query_idx) = tolower(*(query_ptr + query_idx));
        query_idx++;
    }
    *(query + query_idx + 1) = '\0';
    return true;
}

2. cat2.html + cat3.html are no longer in the directories I think I saw someone say to email someone with the code to check, is that the case?

**3. I can't load 2 files ** Not sure what's going on here - I can load cat.html and cat.jpg successfully separately.

Thanks for any help!

3 hopefully 'quick' issues if someone could help?

1) My query parser for php isn't working. I thought believe I've done it right, so I'd appreciate some help here. CS50 check one passed fine, but check 2 gives me errors

Requesting hello.php? returns 200, text/html, and correct output \ expected output, not an exit code of 0

:( Requesting hello.php?name=Alice returns 200, text/html, and correct output \ expected output, not an exit code of 0

Here's the code for my parse (can remove once answered)

if (strchr(line, '?') == NULL)
// look for a query; if there is none - set it equal to null terminator as spec'ed
{
    *query = '\0';
    return true; 

}
char* query_ptr = strchr(line, '?');
// otherwise, you should have ? and a valid pointer to it with strchr
if (query_ptr == NULL)
{
// make sure you get a valid pointer;
    error(501);
    return false;
    
}

else if (*query_ptr + 1 == ' ')
// check if there is nothing after the question mark - if so, again query is ""
{
    *query = '\0';
}
else
// otherwise, start from 1 after the question mark and copy the lowercase query into the index and null terminate
{
    query_ptr++;
    int query_idx = 0;
    while(*query_ptr + query_idx != ' ')
    {
        *(query + query_idx) = tolower(*(query_ptr + query_idx));
        query_idx++;
    }
    *(query + query_idx + 1) = '\0';
    return true;
}

2. cat2.html + cat3.html are no longer in the directories I think I saw someone say to email someone with the code to check, is that the case?

**3. I can't load 2 files ** Not sure what's going on here - I can load cat.html and cat.jpg successfully separately.

Thanks for any help!

3 hopefully 'quick' issues if someone could help?

1) My query parser for php isn't working. I thought believe I've done it right, so I'd appreciate some help here. CS50 check one passed fine, but check 2 gives me errors

Requesting hello.php? returns 200, text/html, and correct output \ expected output, not an exit code of 0

:( Requesting hello.php?name=Alice returns 200, text/html, and correct output \ expected output, not an exit code of 0

Here's the code for my parse (can remove once answered)

if (strchr(line, '?') == NULL)
// look for a query; if there is none - set it equal to null terminator as spec'ed
{
    *query = '\0';
    return true; 

}
char* query_ptr = strchr(line, '?');
// otherwise, you should have ? and a valid pointer to it with strchr
if (query_ptr == NULL)
{
// make sure you get a valid pointer;
    error(501);
    return false;
    
}

else if (*(query_ptr + 1) == ' ')
// check if there is nothing after the question mark - if so, again query is ""
{
    *query = '\0';
}
else
// otherwise, start from 1 after the question mark and copy the lowercase query into the index and null terminate
{
    query_ptr++;
    int query_idx = 0;
    while(*(query_ptr + query_idx) != ' ')
    {
        *(query + query_idx) = tolower(*(query_ptr + query_idx));
        query_idx++;
    }
    *(query + query_idx + 1) = '\0';
    return true;
}

2. cat2.html + cat3.html are no longer in the directories I think I saw someone say to email someone with the code to check, is that the case?

**3. I can't load 2 files ** Not sure what's going on here - I can load cat.html and cat.jpg successfully separately.

Thanks for any help!

Source Link
borker
  • 301
  • 1
  • 8
Loading