943,799 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 978
  • PHP RSS
Sep 9th, 2008
0

Please Help!! PHP code renders in blank :(

Expand Post »
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


PHP Syntax (Toggle Plain Text)
  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>
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ocbphoto is offline Offline
24 posts
since Aug 2008
Sep 10th, 2008
0

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

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.

Click to Expand / Collapse  Quote originally posted by ocbphoto ...
Guys i am going crazy here I dont know what I am doing wrong here, it renders in blank the page.
PHP Syntax (Toggle Plain Text)
  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 '}'.
Click to Expand / Collapse  Quote originally posted by ocbphoto ...
PHP Syntax (Toggle Plain Text)
  1. }
Click to Expand / Collapse  Quote originally posted by ocbphoto ...
PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 15
Solved Threads: 1
Newbie Poster
tgbyhn is offline Offline
8 posts
since Sep 2008
Sep 10th, 2008
0

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

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
Reputation Points: 15
Solved Threads: 1
Newbie Poster
tgbyhn is offline Offline
8 posts
since Sep 2008
Sep 10th, 2008
0

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

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ocbphoto is offline Offline
24 posts
since Aug 2008
Sep 10th, 2008
0

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

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.
Reputation Points: 21
Solved Threads: 11
Junior Poster
MVied is offline Offline
111 posts
since Aug 2008
Sep 10th, 2008
0

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

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



PHP Syntax (Toggle Plain Text)
  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>
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ocbphoto is offline Offline
24 posts
since Aug 2008
Sep 10th, 2008
0

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

This is the example of what i want to do:

http://bikeoptions.com/cr1_search.php

thank you
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ocbphoto is offline Offline
24 posts
since Aug 2008
Sep 10th, 2008
0

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

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.
Reputation Points: 21
Solved Threads: 11
Junior Poster
MVied is offline Offline
111 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: problem with include files...
Next Thread in PHP Forum Timeline: Distributing an HTML email to a mailing list





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC