3raser Posted February 24, 2010 Share Posted February 24, 2010 <?php $code = $_POST['code']; $dbhost = "****"; $db = "****"; $dbuser = "****"; $dbpassword = "****"; //connecting to the database $connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!"); mysql_select_db("$db") or die("Database fail!"); //extract $extract = mysql_query("SELECT * FROM info WHERE vipcode='$code'"); $numrows = mysql_num_rows($extract); while ($row = mysql_fetch_assoc($extract)) { if (!$row[levelofproject] || !$row[name] || !$row[id]){ echo "Invalid code! <a href='http://www.srl.comoj.com'>Home</a>"; } else { if ($row[progress] > 70) { $progress = "green"; } echo "Progress: <span style='color:". $progress ."'>". $row[progress] ."%</span>"; } } ?> And my HTML code: <link rel="stylesheet" type="text/css" href="style.css" /> <br><br><form action='info.php' method='POST'><input type='text' name='code' size='16' align='center'><a href='info.php' type='submit'><img src='Go.png' align='center' border='0'></a></img></form> <Br><br><br><br><br><b><font family='arial'>Warning: Best viewed in Google Chrome</font></b> When I type in a number, and then click the button it sends me to a blank page.......? It DOES send me to info.php, but it's a blank page.... [/code] Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/ Share on other sites More sharing options...
Fergal Andrews Posted February 24, 2010 Share Posted February 24, 2010 Hi Justin, Using a hyperlink to a php page will not submit form data, so when your link goes to info.php there is no form data. The SQL statement therefore will be SELECT * FROM info WHERE vipcode='' which will return no results unless you have a record with a null code value. The conditional statement if (!$row[levelofproject] || !$row[name] || !$row[id]){ therefore fails and nothing is output to the screen. All the best, Fergal You need to use a proper method of submitting the form, either a submit input or javascript and put a form action with info.php as the value in the form tag. Fergal Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1017754 Share on other sites More sharing options...
teamatomic Posted February 24, 2010 Share Posted February 24, 2010 Try using a submit button instead of a link with graphic, if you want an image try: <input type="image" name="submit" src="button.png" /> HTH Teamtomic Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1017757 Share on other sites More sharing options...
3raser Posted February 24, 2010 Author Share Posted February 24, 2010 I don't think that'll work.... Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1017771 Share on other sites More sharing options...
3raser Posted February 24, 2010 Author Share Posted February 24, 2010 Wtf, I can't edit my post?.... Well here is my new HTML code: <link rel="stylesheet" type="text/css" href="style.css" /> <br><br><form action='info.php' method='POST'><input type='text' name='code' size='16'><input type='submit' value='Go'></form> Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1017776 Share on other sites More sharing options...
3raser Posted February 25, 2010 Author Share Posted February 25, 2010 Bump Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018231 Share on other sites More sharing options...
shlumph Posted February 25, 2010 Share Posted February 25, 2010 We don't know what's on info.php.... is it the first block of code you posted? If so, there may be no records in your database, or an error on the page. Try this: ini_set('display_errors', E_ALL); display_errors(1); And also print out some debugging info on that page... Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018238 Share on other sites More sharing options...
3raser Posted February 25, 2010 Author Share Posted February 25, 2010 Ok, I put that code in. It shows this error: Fatal error: Call to undefined function display_errors() in /home/a2662105/public_html/info.php on line 3 Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018248 Share on other sites More sharing options...
ronvanb Posted February 25, 2010 Share Posted February 25, 2010 The code can't find the function display_errors(). Maybe you forgot to include the function in info.php Or made a type mistake in the function name. It just cant find the function. If you call a function name that does not exist. You will get this error. I think that is the solution. Hope you will get it to work Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018267 Share on other sites More sharing options...
3raser Posted February 25, 2010 Author Share Posted February 25, 2010 The code can't find the function display_errors(). Maybe you forgot to include the function in info.php Or made a type mistake in the function name. It just cant find the function. If you call a function name that does not exist. You will get this error. I think that is the solution. Hope you will get it to work I'm not sure of what might be wrong. I'll look though. Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018276 Share on other sites More sharing options...
jl5501 Posted February 25, 2010 Share Posted February 25, 2010 The code to report all errors is this ini_set('display_errors',1); error_reporting(E_ALL); Which is slightly different to what you have been given, so change it to that Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018277 Share on other sites More sharing options...
3raser Posted February 25, 2010 Author Share Posted February 25, 2010 I guess it has something to do with $code Notice: Undefined index: code in /home/a2662105/public_html/info.php on line 5 Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018290 Share on other sites More sharing options...
jl5501 Posted February 26, 2010 Share Posted February 26, 2010 It is saying there is no $_POST['code'] in $_POST So you need to see what is in there print_r($_POST) will show you Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018295 Share on other sites More sharing options...
3raser Posted February 26, 2010 Author Share Posted February 26, 2010 Alright, I added that. Now: Parse error: syntax error, unexpected T_VARIABLE in /home/a2662105/public_html/info.php on line 8 Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018297 Share on other sites More sharing options...
Andy-H Posted February 26, 2010 Share Posted February 26, 2010 <?php if (isset($_POST['submit'])) { $code = isset($_POST['code']) ? intval($_POST['code']) : 0; $dbhost = "****"; $db = "****"; $dbuser = "****"; $dbpassword = "****"; //connecting to the database $connect = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection failed!"); mysql_select_db($db, $connect) or die("Database fail!"); //extract $extract = mysql_query("SELECT * FROM info WHERE vipcode='$code'")or die("Error with query: " . mysql_error()); $numrows = mysql_num_rows($extract); if ($numrows != 0) { echo "Invalid code! <a href='[url=http://www.srl.comoj.com]http://www.srl.comoj.com[/url]'>Home</a>"; } else { while ($row = mysql_fetch_assoc($extract)) { if ($row['progress'] > 70) { $progress = "green"; } echo "Progress: <span style='color:". $progress ."'>". $row['progress'] ."%</span>"; } } } ?> <link rel="stylesheet" type="text/css" href="style.css" > <br > <br > <form action='info.php' method='POST'> <input type='text' name='code' size='16'> <input type='submit' name='submit' value='Go'> </form> Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018309 Share on other sites More sharing options...
sasa Posted February 26, 2010 Share Posted February 26, 2010 try <link rel="stylesheet" type="text/css" href="style.css" /> <br><br> <form action='info.php' method='POST' name='myform'> <input type='text' name='code' size='16' align='center'> <a href='javascript: document.myform.submit()' type='submit'> <img src='Go.png' align='center' border='0' /> </a> </form> <br><br><br><br><br> <b><font family='arial'>Warning: Best viewed in Google Chrome</font></b> Quote Link to comment https://forums.phpfreaks.com/topic/193284-displays-nothing/#findComment-1018392 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.