englishcodemonkey Posted June 24, 2008 Share Posted June 24, 2008 When i run this code nothing shows in the table...Well i guess the table doesn't even show up! I was told this was because of the SQL connection or query?? I know my connection is correct because I have other PHP scripts running correctly from it?? Here is how my table is set up. This is confusing me because I had it working perfect on localhost. CREATE TABLE HOSTA ( hosta_id INT AUTO_INCREMENT PRIMARY KEY, hosta_name VARCHAR(50) NOT NULL, hybridizer VARCHAR(50), size VARCHAR(10), description VARCHAR (200), price DECIMAL(3,2)); <?php require_once('conn.php'); $hosta = $_REQUEST['hosta']; $hosta1 = $_REQUEST['hosta']; $q = "SELECT hybridizer, size, price, description from hostajess where hosta_name='$hosta'"; $r = @mysqli_query ($dbc, $q); if ($r) { echo ' <table align="center" cellspacing="3" cellpadding="3" width="75%"> <tr> <td align="left" width="33.3%">Hybridizer</td> <td align="left" width="33.3%">Size</td> <td align="left" >Price</td> </tr>'; while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) { echo ' <tr> <td align="left">' .$row['hybridizer'] . '</td> <td align="left">' .$row['size'] . '</td> <td align="left">' .$row['price']. '</td> </tr>'; } } echo '</table>'; $q = "SELECT description from hostajess where hosta_name='$hosta1'"; $r = mysqli_query ($dbc, $q); if ($r) { echo ' <table align="center" cellspacing="3" cellpadding="3" width="75%"> <tr> <td align="left">Description</td> </tr>'; while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) { echo ' <tr> <td align="justify">' .$row['description'] . '</td> </tr>'; } } echo '</table>'; mysqli_close($dbc); ?> This is really frustrating me! thanks for all your help! Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted June 24, 2008 Share Posted June 24, 2008 your query is selecting from a table "hostajess" but you've created a table named "HOSTA". Quote Link to comment Share on other sites More sharing options...
englishcodemonkey Posted June 25, 2008 Author Share Posted June 25, 2008 I tried that already if you need more info the problem is on this page...http://www.wadeandgattonnurseries.com/hosta_new.html Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted June 25, 2008 Share Posted June 25, 2008 Tried what already? If your table's name is HOSTA, you have to say "SELECT * FROM HOSTA" it can't be anything FROM hostajess... hostajess doesn't exist(as afar as I know) Quote Link to comment Share on other sites More sharing options...
englishcodemonkey Posted June 25, 2008 Author Share Posted June 25, 2008 The table on my local MySQL is called 'hosta'. The table I created on my host is called 'hostajess'. I posted the code that I used to set up the table because that has the fields in, forgetting that I had changed the name. The code for the table should have been posted as: CREATE TABLE hostajess ( hosta_id INT AUTO_INCREMENT PRIMARY KEY, hosta_name VARCHAR(50) NOT NULL, hybridizer VARCHAR(50), size VARCHAR(10), description VARCHAR (200), price DECIMAL(3,2)); Sorry for the confusion! Quote Link to comment Share on other sites More sharing options...
revraz Posted June 25, 2008 Share Posted June 25, 2008 Use mysqli_error after your query to see if it's failing. Quote Link to comment Share on other sites More sharing options...
englishcodemonkey Posted June 25, 2008 Author Share Posted June 25, 2008 Ok i added: mysqli_error($dbc); but when i select the option from the drop down box and click the submit button i still get just a blank page???? Any ideas? Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted June 26, 2008 Share Posted June 26, 2008 you need to do the error function as: $result = mysql_query("QUERY") or die(mysql_error()); that should show the error also, when you get the blank page, view the source and see if anything is printing. Like the </table> tag that you have set to output whether $r is true or not. If it does display, then there's an error grabbing the data. If it's blank, then you have error in the code. Quote Link to comment Share on other sites More sharing options...
englishcodemonkey Posted June 26, 2008 Author Share Posted June 26, 2008 Ok so i'm not quiet sure what the problem was but it's working ok now! Thanks everyone though 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.