gingercrock Posted February 15, 2006 Share Posted February 15, 2006 hey guys, i am doing a project at the moment which is basically a friends reunited type of website.. i have created a database but the searches do not work.. this is the code i have for when the 'search' button is pressed:<?php$connection = mysql_connect("sentinel.cs.cf.ac.uk","scm5sjc","put_password_here");mysql_select_db("sjcdb",$connection) or die("failed!");$result = mysql_query("SELECT * FROM info", $connection);while($row = mysql_fetch_row($result)) {$title = $row[1];$first = $row[2];$last = $row[3];$age = $row[4];$subject = $row[5];$initial=$row[6];$email=$row[7];for ($i=0; $i<mysql_num_fields($result); $i++) print $row[$i]." ";echo "\n";print $title." ";print $first." "; print $last ." ";print $age ." ";print $subject." "; print $initial." ";print $email." ";}mysql_close($connection);?></pre>all that appears when the button is pressed is this code, any advice of where i may have gone wrong would be great, thanks.steve Quote Link to comment Share on other sites More sharing options...
fenway Posted February 15, 2006 Share Posted February 15, 2006 First, you might consider using mysql_fetch_assoc($result) instead, so that you don't have to do those variable assignments -- you'd get back $row['title'], etc.Second, are you sure there's no query error? You have no mysql_error() call.Hope that helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.