So I'm basically having the same problem with this.

[Pset6 Undefined index: name in /home/jharvard/Dropbox/pset6/public/hello.php on line 8

But changing "name" into "q" in hello.php did not work. I checked command variable with GDB but it seems correct. (pass and query is optimized out, but as I see command I guess it doesn't matter)

Here's what I got in terminal with gdb

Listening on port 8080
GET /hello.html HTTP/1.1
HTTP/1.1 200 OK
GET /hello.php?name=Gou HTTP/1.1

Breakpoint 1, main (argc=4, argv=0xbffff194) at server.c:251
251                 char* format = "QUERY_STRING=\"%s\" REDIRECT_STATUS=200 SCRIPT_FILENAME=\"%s\" php-cgi";
(gdb) p path
$4 = <optimized out>
(gdb) n
252                 char command[strlen(format) + (strlen(path) - 2) + (strlen(query) - 2) + 1];
(gdb) n
253                 sprintf(command, format, query, path);
(gdb) n
254                 file = popen(command, "r");
(gdb) p path
$5 = <optimized out>
(gdb) p query
$6 = <optimized out>
(gdb) p command
$7 = 0xbfffee30 "QUERY_STRING=\"Gou\" REDIRECT_STATUS=200 SCRIPT_FILENAME=\"/home/jharvard/Dropbox/pset6/public/hello.php\" php-cgi"
(gdb) n
255                 if (file == NULL)
(gdb) PHP Notice:  Undefined index: name in /home/jharvard/Dropbox/pset6/public/hello.php on line 8
PHP Stack trace:
PHP   1. {main}() /home/jharvard/Dropbox/pset6/public/hello.php:0

Any possible reason for the error?


it appears that you're not extracting the query string correctly. I could tell from the command string which shows


where it should be

  • Wow thanks it solved the problem.Actucally it was written in pset instruction, but I thought that only after = matters...
    – Tatch
    Dec 5 '15 at 10:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .