RecklessCounty Posted July 14, 2007 Share Posted July 14, 2007 can someone tell me why my code doesn't work? <?php /** * @author ShannenName * @copyright 2007 */ session_start(); require "global_func.php"; if ($_SESSION['loggedin'] == 0) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is = mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid", $c) or die(mysql_error()); $ir = mysql_fetch_array($is); check_level(); $fm = money_formatter($ir['money']); $lv = date('F j, Y, g:i a', $ir['laston']); $h->userdata($ir, $lv, $fm); $h->menuarea(); if ($ir['user_level'] != 2) { print "You sneak, get out of here!"; $h->endpage(); exit; } $posta = mysql_real_escape_string(print_r($_POST, 1), $c); $geta = mysql_real_escape_string(print_r($_GET, 1), $c); mysql_query("INSERT INTO adminlogs VALUES('', $userid, '$posta', '$geta', unix_timestamp() )", $c); switch ($_GET['action']) { case "delcity": delcity(); break; case 'newcity': new_city(); break; case 'newcitysub': new_city_sub(); break; case 'editcity': edit_city(); break; case 'editcitysub': edit_city_sub(); break; } print "[[url='newcity.php?action=newcity']Create New city[/url]] [[url='newcity.php?action=editcity']Edit City[/url]] "; function new_city() { global $ir, $c, $h, $userid; print "Create New City This will create a new city. City name: City desc: City min level "; } function new_city_sub() { global $ir, $c, $h, $userid; $_POST['cityminlevel'] = abs((int)$_POST['cityminlevel']); mysql_query("INSERT INTO cities (cityname, citydesc, cityminlevel) VALUES ('{$_POST['cityname']}', '{$_POST['citydesc']}', '{$_POST['cityminlevel']}');", $c); print "[url='admin.php']> Back[/url]"; } function edit_city() { global $ir, $c, $h, $userid, $cityid; print "Edit City This will edit a city. City Name EXACTLY as it appears: City desc: City min level "; } function edit_city_sub() { global $ir,$c,$h,$userid; mysql_query("UPDATE cities (cityname, citydesc, cityminlevel)VALUES ('{$_POST['cityname']}', '{$_POST['citydesc']}', '{$_POST['cityminlevel']}');", $c); print "City edited..."; } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
RecklessCounty Posted July 15, 2007 Author Share Posted July 15, 2007 Re: New City Anyone? **bump** Quote Link to comment Share on other sites More sharing options...
Snatchy Posted July 16, 2007 Share Posted July 16, 2007 Re: New City <?php /** * @author ShannenName * @copyright 2007 */ session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $cm=money_formatter($ir['crystals'],''); $bm=money_formatter($ir['l100bank']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm,$cm); $h->menuarea(); if ($ir['user_level'] != 2) { print "You sneak, get out of here!"; $h->endpage(); exit; } $posta = mysql_real_escape_string(print_r($_POST, 1), $c); $geta = mysql_real_escape_string(print_r($_GET, 1), $c); mysql_query("INSERT INTO adminlogs VALUES('', $userid, '$posta', '$geta', unix_timestamp() )", $c); switch ($_GET['action']) { case "delcity": delcity(); break; case 'newcity': new_city(); break; case 'newcitysub': new_city_sub(); break; case 'editcity': edit_city(); break; case 'editcitysub': edit_city_sub(); break; } print "</br >[[url='newcity01.php?action=newcity']Create New city[/url]] [[url='newcity01.php?action=editcity']Edit City[/url]] City List <table> <tr><td>"; $q=mysql_query("SELECT * FROM cities ",$c); print"<table width=95% bgcolor=#ff9900 align=center border=1 cellspacing=0><tr style='background:#ff6633'><th>city id no.</th><th>Name</th><th>Description</th><th>Min Level</th><th> </th></tr>"; while($r=mysql_fetch_array($q)) { print "<tr><td>{$r['cityid']}</td><td>{$r['cityname']}</td><td>{$r['citydesc']}</td><td>{$r['cityminlevel']}</td></tr>"; } print "</table>"; function new_city() { global $ir, $c, $h, $userid; print "<h3>Create New City</h3> This will create a new city. <form action='newcity01.php?action=newcitysub' method='post'> City name: <input type='text' name='cityname' /> City desc: <input type='text' name='citydesc' /> City min level <input type='text' name='cityminlevel' /> <input type='submit' value='Create New city' /></form>"; } function new_city_sub() { global $ir, $c, $h, $userid; $_POST['cityminlevel'] = abs((int)$_POST['cityminlevel']); mysql_query("INSERT INTO cities (cityname, citydesc, cityminlevel) VALUES ('{$_POST['cityname']}', '{$_POST['citydesc']}', '{$_POST['cityminlevel']}');", $c); print "[url='admin.php']> Back[/url]"; } function edit_city() { global $ir, $c, $h, $userid, $cityid; print "<h3>Edit City</h3> This will edit a city. <form action='newcity01.php?action=editcitysub' method='post'> City City id: <input type='text' name='cityid' /> City Name EXACTLY as it appears: <input type='text' name='cityname' /> City desc: <input type='text' name='citydesc' /> City min level <input type='text' name='cityminlevel' /> <input type='submit' value='Edit city' /></form>"; } function edit_city_sub() { global $ir,$c,$h,$userid; mysql_query("UPDATE cities SET cityid='{$_POST['cityid']}',cityname='{$_POST['cityname']}', citydesc='{$_POST['citydesc']}', cityminlevel='{$_POST['cityminlevel']}' WHERE cityid='{$_POST['cityid']}'",$c); print "City edited..."; } $h->endpage(); ?> Try that Quote Link to comment Share on other sites More sharing options...
Snatchy Posted July 16, 2007 Share Posted July 16, 2007 Re: New City <?php /** * @author ShannenName * @copyright 2007 */ session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $cm=money_formatter($ir['crystals'],''); $bm=money_formatter($ir['l100bank']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm,$cm); $h->menuarea(); if ($ir['user_level'] != 2) { print "You sneak, get out of here!"; $h->endpage(); exit; } $posta = mysql_real_escape_string(print_r($_POST, 1), $c); $geta = mysql_real_escape_string(print_r($_GET, 1), $c); mysql_query("INSERT INTO adminlogs VALUES('', $userid, '$posta', '$geta', unix_timestamp() )", $c); switch ($_GET['action']) { /* case "delcity": delcity(); break;*/ case 'newcity': new_city(); break; case 'newcitysub': new_city_sub(); break; case 'editcity': edit_city(); break; case 'editcitysub': edit_city_sub(); break; case 'delcity': del_city(); break; case 'delcitysub': del_city_sub(); break; } print "</br >[[url='newcity01.php?action=newcity']Create New city[/url]] [[url='newcity01.php?action=editcity']Edit City[/url]] [[url='newcity01.php?action=delcity']Delete City[/url]] City List <table> <tr><td>"; $q=mysql_query("SELECT * FROM cities ",$c); print"<table width=95% bgcolor=#ff9900 align=center border=1 cellspacing=0><tr style='background:#ff6633'><th>city id no.</th><th>Name</th><th>Description</th><th>Min Level</th></tr>"; while($r=mysql_fetch_array($q)) { print "<tr><td>{$r['cityid']}</td><td>{$r['cityname']}</td><td>{$r['citydesc']}</td><td>{$r['cityminlevel']}</td></tr>"; } print "</table>"; function new_city() { global $ir, $c, $h, $userid; print "<h3>Create New City</h3> This will create a new city. <form action='newcity01.php?action=newcitysub' method='post'> City name: <input type='text' name='cityname' /> City desc: <input type='text' name='citydesc' /> City min level <input type='text' name='cityminlevel' /> <input type='submit' value='Create New city' /></form>"; } function new_city_sub() { global $ir, $c, $h, $userid; $_POST['cityminlevel'] = abs((int)$_POST['cityminlevel']); mysql_query("INSERT INTO cities (cityname, citydesc, cityminlevel) VALUES ('{$_POST['cityname']}', '{$_POST['citydesc']}', '{$_POST['cityminlevel']}');", $c); print "[url='admin.php']> Back[/url]"; } function edit_city() { global $ir, $c, $h, $userid, $cityid; print "<h3>Edit City</h3> This will edit a city. <form action='newcity01.php?action=editcitysub' method='post'> City City id: <input type='text' name='cityid' /> City Name EXACTLY as it appears: <input type='text' name='cityname' /> City desc: <input type='text' name='citydesc' /> City min level <input type='text' name='cityminlevel' /> <input type='submit' value='Edit city' /></form>"; } function edit_city_sub() { global $ir,$c,$h,$userid; mysql_query("UPDATE cities SET cityid='{$_POST['cityid']}',cityname='{$_POST['cityname']}', citydesc='{$_POST['citydesc']}', cityminlevel='{$_POST['cityminlevel']}' WHERE cityid='{$_POST['cityid']}'",$c); print "City edited..."; } function del_city() { global $ir, $c, $h, $userid, $cityid; print "<h3>Delet City</h3> This will delete a city. <form action='newcity01.php?action=delcitysub' method='post'> City id: <input type='text' name='cityid' /> <input type='submit' value='Delete city' /></form>"; } function del_city_sub() { global $ir,$c,$h,$userid; mysql_query("DELETE FROM cities WHERE cityid='{$_POST['cityid']}'",$c); print "City deleted"; } $h->endpage(); ?> 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.