I just...
I just...
I just spent three hours trying to fix a form issue.
Basically I have two forms, one to create a static page and one to create a dynamic page; I create the dynamic page form first and then simply copied the code and made the static page form but when I submitted the static form I didn't get any errors in case I left some fields out (I did get errors on the dynamic form).
So I spent three consecutive hours trying to figure out what the problem was, everything had been renamed properly and the code was exactly identical except for certain form-names. It turns out this was the problem;
Static form, the one that WAS NOT working
[syntax=xhtml]
<form action="pages.php" method="post" id="c_form">
a bunch of fields
</form>[/syntax]
Dynamic form, the one that WAS working
[syntax=xhtml]
<form action="#" method="post" id="c_form">
a bunch of fields
</form>[/syntax]
CAN YOU SPOT THE ERROR IN LESS THAN THREE HOURS?!
I am so fucking angry right now......
Basically I have two forms, one to create a static page and one to create a dynamic page; I create the dynamic page form first and then simply copied the code and made the static page form but when I submitted the static form I didn't get any errors in case I left some fields out (I did get errors on the dynamic form).
So I spent three consecutive hours trying to figure out what the problem was, everything had been renamed properly and the code was exactly identical except for certain form-names. It turns out this was the problem;
Static form, the one that WAS NOT working
[syntax=xhtml]
<form action="pages.php" method="post" id="c_form">
a bunch of fields
</form>[/syntax]
Dynamic form, the one that WAS working
[syntax=xhtml]
<form action="#" method="post" id="c_form">
a bunch of fields
</form>[/syntax]
CAN YOU SPOT THE ERROR IN LESS THAN THREE HOURS?!
I am so fucking angry right now......
Re: I just...
the difference I can spot is pages.php instead of #
Was that it?
I know the feeling. I struggled with a typo for 45 minutes today.
Was that it?
I know the feeling. I struggled with a typo for 45 minutes today.
Re: I just...
I spend three hours on this code yesterday
Here is the wrong one
[syntax=text]pro plot_solar_wind
openr, file, 'files/solar_wind.dat', /get_lun
header = ''
for i = 0, 60 do readf, file, header
month_hours = fltarr(31 * 24)
Vsw = fltarr(31 * 24)
Nsw = fltarr(31 * 24)
Psw = fltarr(31 * 24)
Rmp = fltarr(31 * 24)
day = 0
hour = 0
Vsw_in = 0.0
Nsq_in = 0.0
pts = 0
while not eof(file) do begin
readf, file, day, hour, Nsw_in, Vsw_in, format = '(i2, 9x, i2, 10x, d14.5, d14.3)'
month_hours[pts] = (day - 1) * 24 + hour
Vsw[pts] = Vsw_in
Nsw[pts] = Nsw_in
; print, Vsw_in
pts += 1
endwhile
free_lun, file
openw, file, 'files/some_kind_of_data.dat', /get_lun
for i = 0, pts - 1 do begin
if Vsw[i] le 0 then Vsw[i] = !Values.F_NaN
if Nsw[i] le 0 then Nsw[i] = !Values.F_NaN
if Vsw[i] gt 0 and Nsw[i] gt 0 then begin
Vsw[i] *= 1E+3
Nsw[i] *= 1E-6
; print, Vsw[i], Nsw[i]
Psw[i] = (1.67262E-27 * Nsw[i]) * (Vsw[i] ^ 2)
Rmp[i] = ((31000E-9)^2 / (1.2566E-6 * Psw[i]))^(1 / 6.0)
print, Vsw[i], Nsw[i], Psw[i], Rmp[i]
if Rmp[i] gt 6.6 then begin
printf, file, i, Vsw[i], Rmp[i], ' Magnetosphere'
endif else begin
printf, file, i, Vsw[i], Rmp[i], ' Solar wind'
endelse
endif else begin
Psw[i] = !Values.F_NaN
Rmp[i] = !Values.F_NaN
printf, file, i, Vsw[i], Rmp[i], ' No data'
endelse
endfor
free_lun, file
window, 1
plot, Vsw, ytitle = 'Speed (m/s)', min = 0
window, 2
plot, Nsw, ytitle = 'Density (#/m^3)', min = 0
window, 3
plot, Psw, ytitle = 'Pressure (#/m^3)', min = 0
end
[/syntax]
And here is the right one
[syntax=text]pro plot_solar_wind
openr, file, 'files/solar_wind.dat', /get_lun
header = ''
for i = 0, 60 do readf, file, header
month_hours = fltarr(31 * 24)
Vsw = fltarr(31 * 24)
Nsw = fltarr(31 * 24)
Psw = fltarr(31 * 24)
Rmp = fltarr(31 * 24)
day = 0
hour = 0
Vsw_in = 0.0
Nsq_in = 0.0
pts = 0
while not eof(file) do begin
readf, file, day, hour, Nsw_in, Vsw_in, format = '(i2, 9x, i2, 10x, d14.5, d14.3)'
month_hours[pts] = (day - 1) * 24 + hour
Vsw[pts] = Vsw_in
Nsw[pts] = Nsw_in
; print, Vsw_in
pts += 1
endwhile
free_lun, file
openw, file, 'files/some_kind_of_data.dat', /get_lun
for i = 0, pts - 1 do begin
if Vsw[i] le 0 then Vsw[i] = !Values.F_NaN
if Nsw[i] le 0 then Nsw[i] = !Values.F_NaN
if Vsw[i] gt 0 and Nsw[i] gt 0 then begin
Vsw[i] *= 1E+3
Nsw[i] *= 1E+6
; print, Vsw[i], Nsw[i]
Psw[i] = (1.67262E-27 * Nsw[i]) * (Vsw[i] ^ 2)
Rmp[i] = ((31000E-9)^2 / (1.2566E-6 * Psw[i]))^(1 / 6.0)
print, Vsw[i], Nsw[i], Psw[i], Rmp[i]
if Rmp[i] gt 6.6 then begin
printf, file, i, Vsw[i], Rmp[i], ' Magnetosphere'
endif else begin
printf, file, i, Vsw[i], Rmp[i], ' Solar wind'
endelse
endif else begin
Psw[i] = !Values.F_NaN
Rmp[i] = !Values.F_NaN
printf, file, i, Vsw[i], Rmp[i], ' No data'
endelse
endfor
free_lun, file
window, 1
plot, Vsw, ytitle = 'Speed (m/s)', min = 0
window, 2
plot, Nsw, ytitle = 'Density (#/m^3)', min = 0
window, 3
plot, Psw, ytitle = 'Pressure (#/m^3)', min = 0
end
[/syntax]
Who see the difference without cheating
Here is the wrong one
[syntax=text]pro plot_solar_wind
openr, file, 'files/solar_wind.dat', /get_lun
header = ''
for i = 0, 60 do readf, file, header
month_hours = fltarr(31 * 24)
Vsw = fltarr(31 * 24)
Nsw = fltarr(31 * 24)
Psw = fltarr(31 * 24)
Rmp = fltarr(31 * 24)
day = 0
hour = 0
Vsw_in = 0.0
Nsq_in = 0.0
pts = 0
while not eof(file) do begin
readf, file, day, hour, Nsw_in, Vsw_in, format = '(i2, 9x, i2, 10x, d14.5, d14.3)'
month_hours[pts] = (day - 1) * 24 + hour
Vsw[pts] = Vsw_in
Nsw[pts] = Nsw_in
; print, Vsw_in
pts += 1
endwhile
free_lun, file
openw, file, 'files/some_kind_of_data.dat', /get_lun
for i = 0, pts - 1 do begin
if Vsw[i] le 0 then Vsw[i] = !Values.F_NaN
if Nsw[i] le 0 then Nsw[i] = !Values.F_NaN
if Vsw[i] gt 0 and Nsw[i] gt 0 then begin
Vsw[i] *= 1E+3
Nsw[i] *= 1E-6
; print, Vsw[i], Nsw[i]
Psw[i] = (1.67262E-27 * Nsw[i]) * (Vsw[i] ^ 2)
Rmp[i] = ((31000E-9)^2 / (1.2566E-6 * Psw[i]))^(1 / 6.0)
print, Vsw[i], Nsw[i], Psw[i], Rmp[i]
if Rmp[i] gt 6.6 then begin
printf, file, i, Vsw[i], Rmp[i], ' Magnetosphere'
endif else begin
printf, file, i, Vsw[i], Rmp[i], ' Solar wind'
endelse
endif else begin
Psw[i] = !Values.F_NaN
Rmp[i] = !Values.F_NaN
printf, file, i, Vsw[i], Rmp[i], ' No data'
endelse
endfor
free_lun, file
window, 1
plot, Vsw, ytitle = 'Speed (m/s)', min = 0
window, 2
plot, Nsw, ytitle = 'Density (#/m^3)', min = 0
window, 3
plot, Psw, ytitle = 'Pressure (#/m^3)', min = 0
end
[/syntax]
And here is the right one
[syntax=text]pro plot_solar_wind
openr, file, 'files/solar_wind.dat', /get_lun
header = ''
for i = 0, 60 do readf, file, header
month_hours = fltarr(31 * 24)
Vsw = fltarr(31 * 24)
Nsw = fltarr(31 * 24)
Psw = fltarr(31 * 24)
Rmp = fltarr(31 * 24)
day = 0
hour = 0
Vsw_in = 0.0
Nsq_in = 0.0
pts = 0
while not eof(file) do begin
readf, file, day, hour, Nsw_in, Vsw_in, format = '(i2, 9x, i2, 10x, d14.5, d14.3)'
month_hours[pts] = (day - 1) * 24 + hour
Vsw[pts] = Vsw_in
Nsw[pts] = Nsw_in
; print, Vsw_in
pts += 1
endwhile
free_lun, file
openw, file, 'files/some_kind_of_data.dat', /get_lun
for i = 0, pts - 1 do begin
if Vsw[i] le 0 then Vsw[i] = !Values.F_NaN
if Nsw[i] le 0 then Nsw[i] = !Values.F_NaN
if Vsw[i] gt 0 and Nsw[i] gt 0 then begin
Vsw[i] *= 1E+3
Nsw[i] *= 1E+6
; print, Vsw[i], Nsw[i]
Psw[i] = (1.67262E-27 * Nsw[i]) * (Vsw[i] ^ 2)
Rmp[i] = ((31000E-9)^2 / (1.2566E-6 * Psw[i]))^(1 / 6.0)
print, Vsw[i], Nsw[i], Psw[i], Rmp[i]
if Rmp[i] gt 6.6 then begin
printf, file, i, Vsw[i], Rmp[i], ' Magnetosphere'
endif else begin
printf, file, i, Vsw[i], Rmp[i], ' Solar wind'
endelse
endif else begin
Psw[i] = !Values.F_NaN
Rmp[i] = !Values.F_NaN
printf, file, i, Vsw[i], Rmp[i], ' No data'
endelse
endfor
free_lun, file
window, 1
plot, Vsw, ytitle = 'Speed (m/s)', min = 0
window, 2
plot, Nsw, ytitle = 'Density (#/m^3)', min = 0
window, 3
plot, Psw, ytitle = 'Pressure (#/m^3)', min = 0
end
[/syntax]
Who see the difference without cheating
-
- Posts: 534
- Joined: Thu May 05, 2011 8:19 pm
Re: I just...
Okay, i havent got a clue, hint? ;D
I don't like to brag, but I wasn't circumcised. I was circumnavigated.
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Re: I just...
I spotted it!
[syntax=text]**Spoiler**
/
/
/
/
line 48[/syntax]
[syntax=text]**Spoiler**
/
/
/
/
line 48[/syntax]
Re: I just...
jacek wrote:Temor wrote:I spotted it!
It took me at least 2 hours to see that !
I almost cried
I can relate to the feeling. I spent a total of 4 hours debugging today. I wanted to punch something afterwards.
Re: I just...
I wish I could...not debug stuff... Just leave it and it would magically work, or at least not spend several hours on it
Re: I just...
Ooo I have another good one
This one is wrong
[syntax=text]function fill_gaps, in
total = n_elements(in)
i = -1
while i lt total - 1 do begin
++i
if finite(in[i]) eq 0 then begin
gap_start = (i gt 0) ? i - 1 : 0
for c = gap_start + 1, total - 1 do begin
if finite(in[c]) eq 1 then begin
gap_end = c
diff = abs(gap_start - gap_end) + 1
in[gap_start : gap_end] = in[gap_start] + (in[gap_end] - in[gap_start]) * findgen(diff) / (diff - 1)
i = c
break
endif
endfor
endif
endwhile
return, in
end[/syntax]
And here is the correction
[syntax=text]function fill_gaps, in
total = n_elements(in)
i = -1D
while i lt total - 1 do begin
++i
if finite(in[i]) eq 0 then begin
gap_start = (i gt 0) ? i - 1 : 0
for c = gap_start + 1, total - 1 do begin
if finite(in[c]) eq 1 then begin
gap_end = c
diff = abs(gap_start - gap_end) + 1
in[gap_start : gap_end] = in[gap_start] + (in[gap_end] - in[gap_start]) * findgen(diff) / (diff - 1)
i = c
break
endif
endfor
endif
endwhile
return, in
end[/syntax]
anyone guess how long that took ?!
This one is wrong
[syntax=text]function fill_gaps, in
total = n_elements(in)
i = -1
while i lt total - 1 do begin
++i
if finite(in[i]) eq 0 then begin
gap_start = (i gt 0) ? i - 1 : 0
for c = gap_start + 1, total - 1 do begin
if finite(in[c]) eq 1 then begin
gap_end = c
diff = abs(gap_start - gap_end) + 1
in[gap_start : gap_end] = in[gap_start] + (in[gap_end] - in[gap_start]) * findgen(diff) / (diff - 1)
i = c
break
endif
endfor
endif
endwhile
return, in
end[/syntax]
And here is the correction
[syntax=text]function fill_gaps, in
total = n_elements(in)
i = -1D
while i lt total - 1 do begin
++i
if finite(in[i]) eq 0 then begin
gap_start = (i gt 0) ? i - 1 : 0
for c = gap_start + 1, total - 1 do begin
if finite(in[c]) eq 1 then begin
gap_end = c
diff = abs(gap_start - gap_end) + 1
in[gap_start : gap_end] = in[gap_start] + (in[gap_end] - in[gap_start]) * findgen(diff) / (diff - 1)
i = c
break
endif
endfor
endif
endwhile
return, in
end[/syntax]
anyone guess how long that took ?!
Re: I just...
I found it! line 5
It took me around 10 seconds to spot it, but if it was me who wrote it it would probably take an hour and a half, so that's my guess
It took me around 10 seconds to spot it, but if it was me who wrote it it would probably take an hour and a half, so that's my guess