pratkal Posted April 11, 2011 Author Share Posted April 11, 2011 when i visit mydomain.com/search.php?stream=0 the script post all the result from stream = 0 from sql user ( stream 0 is shown in result as Math )when i visit mydomain.com/search.php?stream=1 ( stream id = 1 from sql ) the script show no result @ all Link to comment Share on other sites More sharing options...
birbal Posted April 11, 2011 Share Posted April 11, 2011 make sure that any rows returning or not when you pass 1 or rather than 0. you may add this line after mysql_query to be confirm. echo mysql_num_rows($result); it will show the return rows number.what is it printing? Link to comment Share on other sites More sharing options...
pratkal Posted April 11, 2011 Author Share Posted April 11, 2011 it fails meit shows me 33 ( 3,3 as there are 2 data for the sheet )while no result for other streamsthis script was working just the fine when i was using it for single row result no loop Link to comment Share on other sites More sharing options...
birbal Posted April 11, 2011 Share Posted April 11, 2011 and one more thing $row = mysql_fetch_assoc($result);you should remove it. everytime you will use mysql_fetch_* internal resource pointer will move forward.So it could create unwanted trouble. Link to comment Share on other sites More sharing options...
pratkal Posted April 11, 2011 Author Share Posted April 11, 2011 well u was dam correct hahahahajust by removing that script worked Link to comment Share on other sites More sharing options...
birbal Posted April 11, 2011 Share Posted April 11, 2011 while no result for other streamsif there is no result it wont show you anything. Link to comment Share on other sites More sharing options...
pratkal Posted April 13, 2011 Author Share Posted April 13, 2011 nvm still didnt worked <?phpinclude 'config.php';$con = mysql_connect("$dbhost","$dbuser","$dbpass");if (!$con) { echo "Unable to connect to DB: " . mysql_error(); exit;}mysql_select_db("$dbname");if (!mysql_select_db("$dbname")) { echo "Unable to select mydbname: " . mysql_error(); exit;}$sql = "SELECT * FROM userWHERE `stream0`={$_GET['stream0']}OR`stream1`={$_GET['stream']}OR `stream2`={$_GET['stream0']}";$result = mysql_query($sql) or exit . mysql_error();$stream[0]="Math";$stream[1]="Physics";$stream[2]="Chemistry";$stream[3]="Computers Basic";$stream[4]="Computer laungages";$stream[5]="Computer Hardware";$stream[6]="Engg - M1 , M2 , M3";$stream[7]="English";$stream[8]="Management";$stream[9]="Principle";$stream[10]="Vice Principle";$stream[11]="Adminstartive";$stream[12]="Other";// While a row of data exists, put that row in $row as an associative array// Note: If you're expecting just one row, no need to use a loop// Note: If you put extract($row); inside the following loop, you'll// then create $userid, $fullname, and $userstatuswhile ($row = mysql_fetch_assoc($result)) {echo "USer Registration ID ";echo $row['id'] . "<BR>";echo "Name-";echo $row['name'] . "<BR>";echo "Email-";echo $row['email'] . "<BR>";echo "Mobile";echo $row['contact'] . "<BR>";echo "stream"; echo $stream[$_GET['stream']] . "<BR>";; echo Age;echo $row['date'];echo $row['month'];echo $row['year'] . "<BR>";}mysql_close($con);?> why and is now presenting me with any result?sql seems to be working on phpmyadmin SELECT * FROM userWHERE `stream0` =5OR `stream1` =3OR `stream2` =2LIMIT 0 , 30 Link to comment Share on other sites More sharing options...
birbal Posted April 13, 2011 Share Posted April 13, 2011 what is the echo of $sql?. You need to check it that all expected data are coming or not from $_GET Link to comment Share on other sites More sharing options...
pratkal Posted April 13, 2011 Author Share Posted April 13, 2011 the request data is coming because script work fine earlier for 1 single searchok did a quick changeand was able to echo out the stream valueok edited the code little$st=$_GET['stream'];echo $st;$sql = "SELECT * FROM userWHERE stream0={$st}OR stream1={$st}OR stream2={$st}limit 0-100";what is possible mistake here Link to comment Share on other sites More sharing options...
justsomeguy Posted April 13, 2011 Share Posted April 13, 2011 Does that mean you're not going to bother to print the query and check? Link to comment Share on other sites More sharing options...
pratkal Posted April 13, 2011 Author Share Posted April 13, 2011 i did run it the new code give the error the old 1 was fine no error in sql at least printed Link to comment Share on other sites More sharing options...
justsomeguy Posted April 13, 2011 Share Posted April 13, 2011 In addition to the code, we need to see the output. Print the sql statement after you create it and paste that here. Link to comment Share on other sites More sharing options...
pratkal Posted April 13, 2011 Author Share Posted April 13, 2011 i guess u meant sql table id int(11) No None AUTO_INCREMENT username varchar(25) latin1_swedish_ci No None password varchar(25) latin1_swedish_ci No None name varchar(25) latin1_swedish_ci No None email varchar(25) latin1_swedish_ci No None ###### varchar(10) latin1_swedish_ci No None date varchar(25) latin1_swedish_ci No None month varchar(25) latin1_swedish_ci No None year varchar(25) latin1_swedish_ci No None edu varchar(500) latin1_swedish_ci No None contact varchar(10) latin1_swedish_ci No None sal int(10) No None address varchar(100) latin1_swedish_ci No None stream0 varchar(500) latin1_swedish_ci No None stream1 varchar(500) latin1_swedish_ci No None stream2 varchar(500) latin1_swedish_ci No None status varchar(500) latin1_swedish_ci No None esal int(10) No None currentjob varchar(100) latin1_swedish_ci No None about varchar(500) latin1_swedish_ci Yes NULL djob varchar(500) latin1_swedish_ci No None Link to comment Share on other sites More sharing options...
birbal Posted April 13, 2011 Share Posted April 13, 2011 you need to echo this $sql $sql = "SELECT * FROM userWHERE `stream0`={$_GET['stream0']}OR`stream1`={$_GET['stream']}OR `stream2`={$_GET['stream0']}"; Link to comment Share on other sites More sharing options...
pratkal Posted April 13, 2011 Author Share Posted April 13, 2011 nvm work the code birbal was correct but the error in code was a typo done in start thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.