Note that there are some explanatory texts on larger screens.

plurals
  1. POstrange urldecode dilemma
    primarykey
    data
    text
    <p>I am passing variables to another page with this urlencoded string</p> <pre><code>http://localhost:8888/proseat/index.php/configure/ve/Honda/Civic+%28sedan%29/2007 </code></pre> <p>and when I use urldecode to get back the variables everything seems fine. I am using codeigniter here, so after printing out the decoded variables I see the following:</p> <pre><code>Honda Civic (sedan) 2007 </code></pre> <p>When I pass the variables off to be used for sql I get nothing back. The weird thing is if I pass the string "Civic (sedan)" everything works fine.</p> <p>First I am encoding the url:</p> <pre><code>function fr () { if ( isset($_POST) ) { $make = (urlencode($this-&gt;input-&gt;post('make'))); $model = (urlencode($this-&gt;input-&gt;post('model'))); $year = (urlencode($this-&gt;input-&gt;post('year'))); redirect('configure/ve/'.$make. '/' . $model. '/' .$year); } } </code></pre> <p>Then, I decode and pass off to another function for processing. </p> <pre><code>function ve ($make, $model, $year) { if ( isset($make,$model,$year) ) { $data['make'] = trim(urldecode($make)); $data['model'] = trim(urldecode($model)); $data['year'] = trim(urldecode($year)); $data['makes'] = $this-&gt;model_cars-&gt;getAllMakes(); //get all the years makes and models $data['models'] = $this-&gt;model_cars-&gt;getAllModels($data['make']); $data['years'] = $this-&gt;model_cars-&gt;getAllYears($data['make'], $data['model']); $this-&gt;load-&gt;view($this-&gt;session-&gt;userdata('language').'/includes/view_header',$tags); $this-&gt;load-&gt;view($this-&gt;session-&gt;userdata('language').'/configure/view_configure',$data); $this-&gt;load-&gt;view($this-&gt;session-&gt;userdata('language').'/includes/view_footer'); } else //stuff } </code></pre> <p>A dump of the variables:</p> <pre><code> echo var_dump($data['make']).'&lt;br&gt;'; echo var_dump($data['model']).'&lt;br&gt;'; echo var_dump($data['year']).'&lt;br&gt;'; </code></pre> <p>This is the result from that</p> <pre><code>string(5) "Honda" string(21) "Civic (sedan)" string(4) "2007" </code></pre> <p>Finally, this is the function that returns NULL for some reason. </p> <pre><code>function getAllYears ($make, $model) { $result = NULL; $sql = "select distinct year from seatcover_listings where make=? and model=? order by year desc"; $query = $this-&gt;db-&gt;query($sql, array(($make), ($model))); if ($query-&gt;num_rows() &gt; 0) $result = $query-&gt;result_array(); //the format of the returned var will be $somevar['name'] return $result; } </code></pre> <p>I know the function works fine because if I Use the following line everything works fine:</p> <pre><code>$this-&gt;model_cars-&gt;getAllYears($data['make'], 'Civic (sedan)'); </code></pre> <p>I tried using htmlspecialchars_decode before after using urldecode but still nothing. I can't beleive how much time I have spent trying to figure this out. Please help me out here.</p> <p>Here is the result to var_dump($sql, $query);</p> <pre><code>string(88) "select distinct year from seatcover_listings where make=? and model=? order by year desc" object(CI_DB_mysqli_result)#22 (8) { ["conn_id"]=&gt; object(mysqli)#15 (17) { ["affected_rows"]=&gt; int(0) ["client_info"]=&gt; string(6) "5.1.44" ["client_version"]=&gt; int(50144) ["connect_errno"]=&gt; int(0) ["connect_error"]=&gt; NULL ["errno"]=&gt; int(0) ["error"]=&gt; string(0) "" ["field_count"]=&gt; int(1) ["host_info"]=&gt; string(25) "Localhost via UNIX socket" ["info"]=&gt; NULL ["insert_id"]=&gt; int(0) ["server_info"]=&gt; string(6) "5.1.44" ["server_version"]=&gt; int(50144) ["sqlstate"]=&gt; string(5) "00000" ["protocol_version"]=&gt; int(10) ["thread_id"]=&gt; int(270) ["warning_count"]=&gt; int(0) } ["result_id"]=&gt; object(mysqli_result)#26 (5) { ["current_field"]=&gt; int(0) ["field_count"]=&gt; int(1) ["lengths"]=&gt; NULL ["num_rows"]=&gt; int(0) ["type"]=&gt; int(0) } ["result_array"]=&gt; array(0) { } ["result_object"]=&gt; array(0) { } ["custom_result_object"]=&gt; array(0) { } ["current_row"]=&gt; int(0) ["num_rows"]=&gt; int(0) ["row_data"]=&gt; NULL } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload