Please Help!! PHP code renders in blank :(

Reply

Join Date: Aug 2008
Posts: 24
Reputation: ocbphoto is an unknown quantity at this point 
Solved Threads: 1
ocbphoto ocbphoto is offline Offline
Newbie Poster

Please Help!! PHP code renders in blank :(

 
0
  #1
Sep 9th, 2008
Guys i am going crazy here I dont know what I am doing wrong here, it renders in blank the page.

I apreciatte very much your help.

Oma


  1.  
  2. <?php
  3.  
  4.  
  5. //include("functions.php");
  6. //dbConnect();
  7. //ADD YOUR OWN DB CONNECTION HERE
  8.  
  9. ?>
  10.  
  11. <html>
  12.  
  13. <head>
  14. <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  15. <meta name="generator" content="Adobe GoLive" />
  16. <title>cr1_search</title>
  17. </head>
  18.  
  19. <body>
  20. <table border="0" cellspacing="0" cellpadding="10">
  21. <tr>
  22. <FORM name="search" METHOD="POST" >
  23.  
  24. <td align="left" valign="middle"><select name="application" size="1"
  25. onchange="this.form.submit()">
  26. <option value="" <?php checkSelection($application,"");?>>- Select -</option><?php $sql = "SELECT * FROM application ORDER BY application_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  27. $sql1 = "SELECT count(*) AS num_results FROM model WHERE suspension_id LIKE '%$row[application_id]%' ";
  28. $result1 = mysql_query($sql1);
  29. $count = mysql_fetch_array($result1);
  30. $num_of_results = $count[num_results];
  31.  
  32. ?>
  33. <option value="<?=$row['application_id']?>" <?php checkSelection($_POST['application'],$row['application_id']);?>><?=$row['app
  34. lication_name'].' ('.$num_of_results.')';?></option><?php } ?>
  35. </select></td>
  36. <td align="left" valign="middle"><?PHP if ($_POST[application] != '') { ?><select name="manufacturer" size="1" onchange="this.form.submit()">
  37. <option value="" <?php
  38. checkSelection($manufacturer,"");?>>- Select -</option><?php //$sql = "SELECT DISTINCT manufacturer.manufacturer_name,manufacturer.manufacturer_id FROM manufacturer,product WHERE manufacturer.manufacturer_id = product.manufacturer_id AND product.application_id LIKE '%$_POST[application]%' ORDER BY manufacturer_name"; $sql = "SELECT * FROM manufacturer ORDER BY manufacturer_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  39. $sql1 = "SELECT count(DISTINCT model_name) AS num_results FROM model WHERE manufacturer_id LIKE '%$row[manufacturer_id]%' AND suspension_id = '$_POST[application]' ";
  40. $result1 = mysql_query($sql1);
  41. $count = mysql_fetch_array($result1);
  42. $num_of_results = $count[num_results];
  43.  
  44. ?>
  45. <option value="<?=$row['manufacturer_id']?>"
  46. <?php
  47. checkSelection($_POST['manufacturer'],$row['manufacturer_id']);?>><?=$row['m
  48. anufacturer_name'].' ('.$num_of_results.')';?></option><?php } ?>
  49. </select><?PHP
  50. }
  51.  
  52. ?></td>
  53. <td align="left" valign="middle"><?PHP if ($_POST[manufacturer] != '' AND $_POST[application] != '') { ?><select name="model" size="1" onchange="this.form.submit()">
  54. <option value="" <?php
  55. checkSelection($model,"");?>>- Select -</option><?php $sql = "SELECT DISTINCT model_name FROM model WHERE manufacturer_id = '$_POST[manufacturer]' AND suspension_id = '$_POST[application]' ORDER BY model_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  56. //$sql1 = "SELECT count(*) AS num_results FROM product WHERE model_id LIKE '%$row[model_id]%' ";
  57. //$result1 = mysql_query($sql1);
  58. //$count = mysql_fetch_array($result1);
  59. //$num_of_results = $count[num_results];
  60.  
  61. ?>
  62. <option value="<?=$row['model_name']?>" <?php checkSelection($_POST['model'],$row['model_name']);?>><?=$row['model_name'];
  63. ?></option><?php } ?>
  64. </select><?PHP
  65. }
  66. ?></td>
  67. <td align="left" valign="middle"><?PHP if ($_POST[manufacturer] != '' AND $_POST[application] != ''AND $_POST[model] != '') { ?><select name="year" size="1" onchange="this.form.submit()">
  68. <option value="" <?php
  69. checkSelection($year,"");?>>- Select -</option><?php $sql = "SELECT year_name,model_id FROM model WHERE model_name = '$_POST[model]' ORDER BY year_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  70. //$sql1 = "SELECT count(*) AS num_results FROM product WHERE year_id LIKE '%$row[year_id]%' ";
  71. //$result1 = mysql_query($sql1);
  72. //$count = mysql_fetch_array($result1);
  73. //$num_of_results = $count[num_results];
  74.  
  75. ?>
  76. <option value="<?=$row['model_id']?>" <?php checkSelection($_POST['year'],$row['model_id']);?>><?=$row['year_name'];?></
  77. option><?php } ?>
  78. </select><?PHP
  79. }
  80. ?></td>
  81. </FORM></tr>
  82. </table>
  83. <?PHP
  84. if ($_POST[year] != '') {
  85.  
  86. $sql2 = "SELECT * FROM product WHERE model_id LIKE '%$_POST[year]%' ";
  87. $result2 = mysql_query($sql2);
  88. if ($result2 == TRUE) {
  89. while ($info = mysql_fetch_array($result2)) {
  90.  
  91. ?>
  92. <table width="180" border="1" cellspacing="2" cellpadding="0">
  93. <tr>
  94. <td>Image</td>
  95. <td>Description</td>
  96. <td>Option</td>
  97. </tr>
  98. <tr>
  99. <td><a title="<?=$info['product_name']?>"
  100. href="<?=$info['large_pic']?>" target="_new"><img
  101. src="<?=$info['small_pic']?>" border="0"></a></td>
  102. <td><?=$info['product_name'];?></td>
  103. <td></td>
  104. </tr>
  105. </table>
  106. <?PHP
  107. }
  108. }
  109. if ($result2 == FALSE) {
  110. $search_error = "Sorry no products are currently available for your search."; }
  111.  
  112. }
  113. ?><?=$search_error;?>
  114. </body>
  115.  
  116. </html>
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 8
Reputation: tgbyhn is an unknown quantity at this point 
Solved Threads: 1
tgbyhn tgbyhn is offline Offline
Newbie Poster

Re: Please Help!! PHP code renders in blank :(

 
0
  #2
Sep 10th, 2008
Hi Oma,

There's a parse error in your code, you need to remove the extra '}'. I've split up your code so you can see where the error is.

Originally Posted by ocbphoto View Post
Guys i am going crazy here I dont know what I am doing wrong here, it renders in blank the page.
  1.  
  2. <?php
  3.  
  4.  
  5. //include("functions.php");
  6. //dbConnect();
  7. //ADD YOUR OWN DB CONNECTION HERE
  8.  
  9. ?>
  10.  
  11. <html>
  12.  
  13. <head>
  14. <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  15. <meta name="generator" content="Adobe GoLive" />
  16. <title>cr1_search</title>
  17. </head>
  18.  
  19. <body>
  20. <table border="0" cellspacing="0" cellpadding="10">
  21. <tr>
  22. <FORM name="search" METHOD="POST" >
  23.  
  24. <td align="left" valign="middle"><select name="application" size="1"
  25. onchange="this.form.submit()">
  26. <option value="" <?php checkSelection($application,"");?>>- Select -</option><?php $sql = "SELECT * FROM application ORDER BY application_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  27. $sql1 = "SELECT count(*) AS num_results FROM model WHERE suspension_id LIKE '%$row[application_id]%' ";
  28. $result1 = mysql_query($sql1);
  29. $count = mysql_fetch_array($result1);
  30. $num_of_results = $count[num_results];
  31.  
  32. ?>
  33. <option value="<?=$row['application_id']?>" <?php checkSelection($_POST['application'],$row['application_id']);?>><?=$row['app
  34. lication_name'].' ('.$num_of_results.')';?></option><?php } ?>
  35. </select></td>
  36. <td align="left" valign="middle"><?PHP if ($_POST[application] != '') { ?><select name="manufacturer" size="1" onchange="this.form.submit()">
  37. <option value="" <?php
  38. checkSelection($manufacturer,"");?>>- Select -</option><?php //$sql = "SELECT DISTINCT manufacturer.manufacturer_name,manufacturer.manufacturer_id FROM manufacturer,product WHERE manufacturer.manufacturer_id = product.manufacturer_id AND product.application_id LIKE '%$_POST[application]%' ORDER BY manufacturer_name"; $sql = "SELECT * FROM manufacturer ORDER BY manufacturer_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  39. $sql1 = "SELECT count(DISTINCT model_name) AS num_results FROM model WHERE manufacturer_id LIKE '%$row[manufacturer_id]%' AND suspension_id = '$_POST[application]' ";
  40. $result1 = mysql_query($sql1);
  41. $count = mysql_fetch_array($result1);
  42. $num_of_results = $count[num_results];
  43.  
  44. ?>
  45. <option value="<?=$row['manufacturer_id']?>"
  46. <?php
  47. checkSelection($_POST['manufacturer'],$row['manufacturer_id']);?>><?=$row['m
  48. anufacturer_name'].' ('.$num_of_results.')';?></option><?php } ?>
  49. </select><?PHP
You need to remove this '}'.
Originally Posted by ocbphoto View Post
Originally Posted by ocbphoto View Post
  1. ?></td>
  2. <td align="left" valign="middle"><?PHP if ($_POST[manufacturer] != '' AND $_POST[application] != '') { ?><select name="model" size="1" onchange="this.form.submit()">
  3. <option value="" <?php
  4. checkSelection($model,"");?>>- Select -</option><?php $sql = "SELECT DISTINCT model_name FROM model WHERE manufacturer_id = '$_POST[manufacturer]' AND suspension_id = '$_POST[application]' ORDER BY model_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  5. //$sql1 = "SELECT count(*) AS num_results FROM product WHERE model_id LIKE '%$row[model_id]%' ";
  6. //$result1 = mysql_query($sql1);
  7. //$count = mysql_fetch_array($result1);
  8. //$num_of_results = $count[num_results];
  9.  
  10. ?>
  11. <option value="<?=$row['model_name']?>" <?php checkSelection($_POST['model'],$row['model_name']);?>><?=$row['model_name'];
  12. ?></option><?php } ?>
  13. </select><?PHP
  14. }
  15. ?></td>
  16. <td align="left" valign="middle"><?PHP if ($_POST[manufacturer] != '' AND $_POST[application] != ''AND $_POST[model] != '') { ?><select name="year" size="1" onchange="this.form.submit()">
  17. <option value="" <?php
  18. checkSelection($year,"");?>>- Select -</option><?php $sql = "SELECT year_name,model_id FROM model WHERE model_name = '$_POST[model]' ORDER BY year_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  19. //$sql1 = "SELECT count(*) AS num_results FROM product WHERE year_id LIKE '%$row[year_id]%' ";
  20. //$result1 = mysql_query($sql1);
  21. //$count = mysql_fetch_array($result1);
  22. //$num_of_results = $count[num_results];
  23.  
  24. ?>
  25. <option value="<?=$row['model_id']?>" <?php checkSelection($_POST['year'],$row['model_id']);?>><?=$row['year_name'];?></
  26. option><?php } ?>
  27. </select><?PHP
  28. }
  29. ?></td>
  30. </FORM></tr>
  31. </table>
  32. <?PHP
  33. if ($_POST[year] != '') {
  34.  
  35. $sql2 = "SELECT * FROM product WHERE model_id LIKE '%$_POST[year]%' ";
  36. $result2 = mysql_query($sql2);
  37. if ($result2 == TRUE) {
  38. while ($info = mysql_fetch_array($result2)) {
  39.  
  40. ?>
  41. <table width="180" border="1" cellspacing="2" cellpadding="0">
  42. <tr>
  43. <td>Image</td>
  44. <td>Description</td>
  45. <td>Option</td>
  46. </tr>
  47. <tr>
  48. <td><a title="<?=$info['product_name']?>"
  49. href="<?=$info['large_pic']?>" target="_new"><img
  50. src="<?=$info['small_pic']?>" border="0"></a></td>
  51. <td><?=$info['product_name'];?></td>
  52. <td></td>
  53. </tr>
  54. </table>
  55. <?PHP
  56. }
  57. }
  58. if ($result2 == FALSE) {
  59. $search_error = "Sorry no products are currently available for your search."; }
  60.  
  61. }
  62. ?><?=$search_error;?>
  63. </body>
  64.  
  65. </html>
Hope this helps.

Adnan
Last edited by tgbyhn; Sep 10th, 2008 at 12:48 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 8
Reputation: tgbyhn is an unknown quantity at this point 
Solved Threads: 1
tgbyhn tgbyhn is offline Offline
Newbie Poster

Re: Please Help!! PHP code renders in blank :(

 
0
  #3
Sep 10th, 2008
Also you could alter your php.ini file, and change these values to:
error_reporting = E_ALL
display_errors = On

This will show you where the errors are. Although note that "display_errors = On" isn't recommended for production systems and should be Off.

If you prefer not to enable "display_errors" you could look for your web server's error log, as it should be in there too.

Adnan
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 24
Reputation: ocbphoto is an unknown quantity at this point 
Solved Threads: 1
ocbphoto ocbphoto is offline Offline
Newbie Poster

Re: Please Help!! PHP code renders in blank :(

 
0
  #4
Sep 10th, 2008
Adnan thank you for your time, i did the changes you mention above and it render at least now something unfortunately an error but at least is something this:

call to undefined function: check selection() Line30

My webserver is running php5 does it has to do with that
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 84
Reputation: MVied is an unknown quantity at this point 
Solved Threads: 5
MVied's Avatar
MVied MVied is offline Offline
Junior Poster in Training

Re: Please Help!! PHP code renders in blank :(

 
0
  #5
Sep 10th, 2008
It shouldn't. I see you have a file named functions.php included into your file at the top. Look in that file for the checkSelection function and ensure that it is there. Maybe the casing is incorrect, as function and variable names are case sensitive.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 24
Reputation: ocbphoto is an unknown quantity at this point 
Solved Threads: 1
ocbphoto ocbphoto is offline Offline
Newbie Poster

Re: Please Help!! PHP code renders in blank :(

 
0
  #6
Sep 10th, 2008
OK guys I am about to scream, damn so here is my entire CODE, i dont have any functions.php file.

The code was given to me, i am trying to have a list/menu and then pass the result to another list/menu dynamically HONESTLY I DONT KNOW what i am doing wrong here. HELP! Thank you very much



  1. <?php
  2.  
  3. $dbserver = "MYSERVER.com";
  4. $user = "USERME";
  5. $db = "DB2008";
  6. $pwd = "MYPASS";
  7. global $link;
  8. $link = mysql_connect($dbserver,$user,$pwd);
  9. mysql_select_db($db, $link);
  10.  
  11.  
  12. ?>
  13.  
  14.  
  15. <html>
  16.  
  17. <head>
  18. <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  19. <meta name="generator" content="Adobe GoLive" />
  20. <title>cr1_search</title>
  21. </head>
  22.  
  23. <body>
  24. <table border="1" cellspacing="0" cellpadding="10">
  25. <tr>
  26. <FORM name="search" METHOD="POST" >
  27.  
  28. <td align="left" valign="middle"><select name="application" size="1"
  29. onchange="this.form.submit()">
  30. <option value="" <?php checkSelection($application,"");?>>- Select -</option><?php $sql = "SELECT * FROM application ORDER BY application_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  31. $sql1 = "SELECT count(*) AS num_results FROM model WHERE suspension_id LIKE '%$row[application_id]%' ";
  32. $result1 = mysql_query($sql1);
  33. $count = mysql_fetch_array($result1);
  34. $num_of_results = $count[num_results];
  35.  
  36. ?>
  37. <option value="<?=$row['application_id']?>" <?php checkSelection($_POST['application'],$row['application_id']);?>><?=$row['app
  38. lication_name'].' ('.$num_of_results.')';?></option><?php } ?>
  39. </select>
  40. <br>
  41. <br>
  42. <br>
  43. <br></td>
  44. <td align="left" valign="middle"><?PHP if ($_POST[application] != '') { ?><select name="manufacturer" size="1" onChange="this.form.submit()">
  45. <option value="" <?php
  46. checkSelection($manufacturer,"");?>>- Select -</option><?php //$sql = "SELECT DISTINCT manufacturer.manufacturer_name,manufacturer.manufacturer_id FROM manufacturer,product WHERE manufacturer.manufacturer_id = product.manufacturer_id AND product.application_id LIKE '%$_POST[application]%' ORDER BY manufacturer_name"; $sql = "SELECT * FROM manufacturer ORDER BY manufacturer_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  47. $sql1 = "SELECT count(DISTINCT model_name) AS num_results FROM model WHERE manufacturer_id LIKE '%$row[manufacturer_id]%' AND suspension_id = '$_POST[application]' ";
  48. $result1 = mysql_query($sql1);
  49. $count = mysql_fetch_array($result1);
  50. $num_of_results = $count[num_results];
  51.  
  52. ?>
  53. <option value="<?=$row['manufacturer_id']?>"
  54. <?php
  55. checkSelection($_POST['manufacturer'],$row['manufacturer_id']);?>><?=$row['m
  56. anufacturer_name'].' ('.$num_of_results.')';?></option><?php } ?>
  57. </select><?PHP
  58.  
  59. ?></td>
  60. <td align="left" valign="middle"><?PHP if ($_POST[manufacturer] != '' AND $_POST[application] != '') { ?><select name="model" size="1" onChange="this.form.submit()">
  61. <option value="" <?php
  62. checkSelection($model,"");?>>- Select -</option><?php $sql = "SELECT DISTINCT model_name FROM model WHERE manufacturer_id = '$_POST[manufacturer]' AND suspension_id = '$_POST[application]' ORDER BY model_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  63. //$sql1 = "SELECT count(*) AS num_results FROM product WHERE model_id LIKE '%$row[model_id]%' ";
  64. //$result1 = mysql_query($sql1);
  65. //$count = mysql_fetch_array($result1);
  66. //$num_of_results = $count[num_results];
  67.  
  68. ?>
  69. <option value="<?=$row['model_name']?>" <?php checkSelection($_POST['model'],$row['model_name']);?>><?=$row['model_name'];
  70. ?></option><?php } ?>
  71. </select><?PHP
  72. }
  73. ?></td>
  74. <td align="left" valign="middle"><?PHP if ($_POST[manufacturer] != '' AND $_POST[application] != ''AND $_POST[model] != '') { ?><select name="year" size="1" onChange="this.form.submit()">
  75. <option value="" <?php
  76. checkSelection($year,"");?>>- Select -</option><?php $sql = "SELECT year_name,model_id FROM model WHERE model_name = '$_POST[model]' ORDER BY year_name"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) {
  77. //$sql1 = "SELECT count(*) AS num_results FROM product WHERE year_id LIKE '%$row[year_id]%' ";
  78. //$result1 = mysql_query($sql1);
  79. //$count = mysql_fetch_array($result1);
  80. //$num_of_results = $count[num_results];
  81.  
  82. ?>
  83. <option value="<?=$row['model_id']?>" <?php checkSelection($_POST['year'],$row['model_id']);?>><?=$row['year_name'];?></
  84. option><?php } ?>
  85. </select><?PHP
  86. }
  87. ?></td>
  88. </FORM></tr>
  89. </table>
  90. <?PHP
  91. if ($_POST[year] != '') {
  92.  
  93. $sql2 = "SELECT * FROM product WHERE model_id LIKE '%$_POST[year]%' ";
  94. $result2 = mysql_query($sql2);
  95. if ($result2 == TRUE) {
  96. while ($info = mysql_fetch_array($result2)) {
  97.  
  98. ?>
  99. <table width="180" border="1" cellspacing="2" cellpadding="0">
  100. <tr>
  101. <td>Image</td>
  102. <td>Description</td>
  103. <td>Option</td>
  104. </tr>
  105. <tr>
  106. <td><a title="<?=$info['product_name']?>"
  107. href="<?=$info['large_pic']?>" target="_new"><img
  108. src="<?=$info['small_pic']?>" border="0"></a></td>
  109. <td><?=$info['product_name'];?></td>
  110. <td></td>
  111. </tr>
  112. </table>
  113. <?PHP
  114. }
  115. }
  116. if ($result2 == FALSE) {
  117. $search_error = "Sorry no products are currently available for your search."; }
  118.  
  119. }
  120. ?><?=$search_error;?>
  121. </body>
  122.  
  123. </html>
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 24
Reputation: ocbphoto is an unknown quantity at this point 
Solved Threads: 1
ocbphoto ocbphoto is offline Offline
Newbie Poster

Re: Please Help!! PHP code renders in blank :(

 
0
  #7
Sep 10th, 2008
This is the example of what i want to do:

http://bikeoptions.com/cr1_search.php

thank you
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 84
Reputation: MVied is an unknown quantity at this point 
Solved Threads: 5
MVied's Avatar
MVied MVied is offline Offline
Junior Poster in Training

Re: Please Help!! PHP code renders in blank :(

 
0
  #8
Sep 10th, 2008
Well, if you can, try and obtain a copy of functions.php from whomever gave you the code. Apparently there's a function you need and it's missing.

Also, a group of dynamic drop downs like that would be much easier to do with just Javascript that's generated by PHP. Something described in this thread.
Last edited by MVied; Sep 10th, 2008 at 4:35 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC