gangsta life Posted May 6, 2011 Posted May 6, 2011 (edited) i wanted a newspaer with ads on it so user can click the newspaper link and be able to add a title and message and post it for $5000 game cash and underneath it should view there post but i seem to have a problem it dont show the box or anything it shows a blank page can anyone correct this please. am new coder and dont know 100% coding and this code is messy i know so can someone help me so i can learn from my mistake pls appreciate my efforts <?php include "globals.php"; if($_GET['action'] == "add") { print " <h3>Add Advertisement ($5,000)</h3> <table width='80%' border='0' cellspacing='1' class='table'><tr colspan='2'> <th><b>Newspaper:</b></th> </tr> <td> <form action='newspaper.php?action=added' method='post'> <table width='100%'> <tr><td valign=top >Title: </td> <td valign=top > <input type='text' name='npTITLE' class='textbox'> </td></tr> <tr><td valign=top >Message: </td> <td valign=top> <textarea rows=8 cols=40 name='npBODY' class='textbox'></textarea> </td></tr> <tr> <td valign=top> </td> <td valign=top > <input class='textbox' type='submit' value='Place Ad ($5000)' /> </td> </table> </form> "; } if($_GET['action'] == "added") { if($ir['money']>5000) { print "Congratulations, you bought a an ad for \$5,000! "; $q=$db->query("SELECT * FROM newscontent LIMIT 1",$c); $ncontent=mysql_result($q,0,0); $q=$db->query("SELECT * FROM papercontent LIMIT 1",$c); $content=mysql_result($q,0,0); $q=$db->query("SELECT * FROM npaper LIMIT 10"); while($na=mysql_fetch_array($q)) $db->query("UPDATE users SET money=money-5000 WHERE userid=$userid"); $title=str_replace(array("\n"),array(" "),strip_tags($_POST['npTITLE'])); $body=str_replace(array("\n"),array(" "),strip_tags($_POST['npBODY'])); $q=$db->query("INSERT INTO `npaper` VALUES (NULL, '$userid', '$title', '$body', unix_timestamp())"); print "Ad Added! <a href='http://newspaper.php' target='_blank'>>Back</a>"; } else { print "You do not have enough money to add an ad. "; } } ?> Edited May 6, 2011 by gangsta life Quote
lucky3809 Posted May 6, 2011 Posted May 6, 2011 Think I have helped you before your under a new name, anyways have you added the sqls to your database? Before I believe I helped you with a mod you had not added the sqls why you gotten the blank page... Quote
gangsta life Posted May 6, 2011 Author Posted May 6, 2011 i have added everything i think its a script error have you checked Quote
lucky3809 Posted May 6, 2011 Posted May 6, 2011 (edited) Checked it... <?php include "globals.php"; if($_GET['action'] == 'add') { print "<br /> <h3>Add Advertisement ($5,000)</h3><br /> <table width='80%' border='0' cellspacing='1' class=''> <tr colspan='2'> <th><b>Newspaper:</b></th></tr> <td> <form action='newspaper.php?action=added' method='post'> <table width='100%'> <tr> <td valign=top>Title: </td> <td valign=top> <input type='text' name='npTITLE' class='textbox'> </td></tr> <tr> <td valign=top>Message: </td> <td valign=top> <textarea rows=8 cols=40 name='npBODY' class='textbox'></textarea> </td></tr> <tr> <td valign=top> </td> <td valign=top > <input class='textbox' type='submit' value='Place Ad ($5000)' /> </td> </table></form>"; } if($_GET['action'] == 'added') { if($ir['money']<5000) { print "You do not have enough money to add an ad.<br />"; exit; } print "Congratulations, you bought a an ad for \$5,000!"; $q=$db->query("SELECT * FROM newscontent LIMIT 1",$c); $ncontent=mysql_result($q,0,0); $q=$db->query("SELECT * FROM papercontent LIMIT 1",$c); $content=mysql_result($q,0,0); $q=$db->query("SELECT * FROM npaper LIMIT 10"); while($na=mysql_fetch_array($q)) { $db->query("UPDATE users SET money=money-5000 WHERE userid=$userid"); $title=str_replace(array("\n"),array("<br />"),strip_tags($_POST['npTITLE'])); $body=str_replace(array("\n"),array("<br />"),strip_tags($_POST['npBODY'])); $q=$db->query("INSERT INTO `npaper` VALUES (NULL, '$userid', '$title', '$body', unix_timestamp())"); print "Ad Added!<br /><a href='http://newspaper.php' target='_blank'>>Back</a>"; } } ?> Your link in your other page to go to this one needs to be newspaper.php?action=add Your money should not be greater it should be less than 5k... changed that for you also. Edited May 7, 2011 by lucky3809 Quote
lucky3809 Posted May 7, 2011 Posted May 7, 2011 (edited) You did not direct the link to the action like I said... where ever the link is you need to add... newspaper.php?action=add then it will appear... you can't just add newspaper.php that's not how you have your script.. You added actions so they need to be called... If you dont want it that way you need to recode it and make a submit page separate from the form... You currently have if($_GET['action'] == 'add') and if($_GET['action'] == 'added') which you need to add the action to your link... such as I have typed prior... Edited May 7, 2011 by lucky3809 Quote
gangsta life Posted May 7, 2011 Author Posted May 7, 2011 i dont know how to do it can you make me one so i can see or are you talking about the newspaper at the bottom shell ichange that link? Quote
gangsta life Posted May 7, 2011 Author Posted May 7, 2011 i want something where soon as you click the newspaper page the form to come up title , message etc. then once submitted for it to do the script function and work..? Quote
lucky3809 Posted May 7, 2011 Posted May 7, 2011 (edited) OMG your kidding you don't know how to link it? You already have newspaper.php in your other page that you ware clicking... just add ?action=add in your browser put http://www.yourgame.com/newspaper.php?action=add Think you should really learn php look on the net for some tuts... I dont have time to teach lol.... As for it directly showing it, it will directly go to the form if you add the ?action=add to your link... Edited May 7, 2011 by lucky3809 Quote
gangsta life Posted May 7, 2011 Author Posted May 7, 2011 okay i have tried it it did work but i dont want it like that i want it on all on one page so all funtions on one page newspaper.php so basically i dont want action saying then for it to display the table i want it to display then once added the funtion i want it action=added but i removed if($_GET['action'] == 'add') { it doesnt work shows error? Quote
gangsta life Posted May 7, 2011 Author Posted May 7, 2011 http://www.deadland.net login as test and test and see there news paper that what i want.. Quote
gangsta life Posted May 7, 2011 Author Posted May 7, 2011 okay i fixed the table part now the only problems is it dont display the ads?> Quote
gangsta life Posted May 7, 2011 Author Posted May 7, 2011 okay 2 problems its doesnt take my money away and say congratulation and then after added does not vie below? Quote
rulerofzu Posted May 7, 2011 Posted May 7, 2011 Well if you do not wish it like that then perhaps offering lucky a small amount of money as payment or something to get it how you wish it to be. Quote
gangsta life Posted May 7, 2011 Author Posted May 7, 2011 well i do want it like that but a little adjust can you help me basically i want some when you click on news paper it shows table with title, and message section then once added and paid for you ad should display on the same page below the tabel. i have fixed the table section but when i add a ad it say congrats then i still have my money and doesnt display nothing? Quote
W3Theory || Peter Posted May 7, 2011 Posted May 7, 2011 Are you adding in the mysql right then? Quote
lucky3809 Posted May 7, 2011 Posted May 7, 2011 If it's not updating then your if else brackets aren't in the right position in your script...Or else your query is wrong and it's not updating... but imo if it's not displaying anything its your brackets placed wrong... Quote
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.