K
kevin433

  • Aug 7, 2008
  • Joined Mar 20, 2008
  • Hi,
    I'm nearly new at php, but i understand it. My problem is just that i can't code so many things in PHP :bemused:. How can i make a menu on the left side of the browser and in the middle of the page are for example the news. But the menu should not reload when i press a link in the menu. Just the page where the news page was should open the page from the link. Can someone help me with this?

    • i tried this from you:

      $sql = "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON $db_owner.* TO '$db_owner'@'%';";
      if ($make && mysql_query($sql))
      {

      • still doesn't work. I execute it on a local php page. I'm running a apache server

        • It don't give these previliges: $sql = "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON $db_owner.* TO \"$db_owner\"@\"%\";";

          I need it because users on my mysql can then create databases themself. I don't need to do it then.

          • Hi,
            I try do give a mysql user previliges with PHP.
            It work to create a new database, but it don't assign previliges to the user.
            Here is my code:

            <?php
            $name = $_POST['user'];
            $owner = $_POST['owner'];
            
            if (!empty($name) OR !empty($owner))
            {
                $continued = mysql_connect("localhost","root","****");
                if($continued)
                {
                    echo "Connection success.<br>";
                }
                else
                {
                    echo "Connection failed.<br>";
                }
            
            $db_name = $name;
            $db_owner = $owner;
            echo "<br>==>DBname: " . $db_name . "<br>";
            $make = mysql_query("CREATE DATABASE $db_name");
            $sql = "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `$db_owner`.* TO \"$db_owner\"@\"%\";"; 
            if($make)
            {
                echo "Database $db_name created assigned to user $db_owner.<br>";
            }
            else
            {
                echo "Failure creating $db_name.<br>";
                echo "Reason: " . mysql_error() . "<br>";
            }
            unset($name);
            unset($owner);
            }
            else
            {
                echo "No name given yet.<br>";
            }
            ?>
            <html>
            <form method="post">
            Database name:
            <input type="text" name="user" value="">
            <br>
            User to assign the database to:
            <input type="text" name="owner" value="">
            <input type="submit" value="Submit">
            </form>
            </html>

            Can someone help me?

            • thanks i got it work now. I only removed the echo " and added under it ?>

              • Hi,
                I need help with a code who my friend and me downloaded.

                I get always this error when i enter the side:

                Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /web/www/frac/users/m/mafiahome/v3/v4/detective.php on line 52

                And this is my code from the file:

                <?php /* ------------------------- */
                
                  include("_include-jail.php");
                
                /* ------------------------- */ ?>
                
                <head>
                <title>[( StreetzMafia )]</title>
                <link rel="stylesheet" type="text/css" href="css-v1.css">
                
                </head>
                
                
                <body>
                
                <table width=100%>
                <center>
                <?php
                ?>
                <body>
                
                <center><table cellspacing=1 cellpadding=2>
                <FORM METHOD=post ACTION="">
                <tr><td colspan=2 class="mainTxt">Lei en detektiv for og finne ut hvor noen er!</td></tr>
                <tr><td class="mainTxt">Search: </td>
                <td class="mainTxt"><input type="text" name="straf"></td></tr>
                <tr>
                  <td class="mainTxt" colspan="2">Å leie en detektiv koster $2,500<br>
                	* DrapsFunksjonen er åpen fra: 15:00 til 19:00!</td>
                </tr>
                <tr><td></td><td class="mainTxt"><input type="submit" name="submit2" value="Lei en detektiv!"></td></tr></form>
                </table></center>
                
                <?PHP
                $naam					= htmlspecialchars($_POST['naam']);
                $kogels					= htmlspecialchars($_POST['kogels']);
                
                $verdediger1			= mysql_query("SELECT * FROM `[users]` WHERE `login`='{$naam}'");
                $verdediger			= mysql_fetch_object($verdediger1);
                $controle			= mysql_num_rows($verdediger1); 
                
                $weapon				= round($data->weapon+1);
                $protection			= round($verdediger->protection+1);
                
                $detective1						= mysql_query("SELECT * FROM `[detective]` WHERE `zoeker`='{$data->login}' AND `status`='1' AND `naam`='{$verdediger->login}'");
                $detective						= mysql_num_rows($detective1);
                
                $lastattempt1					= mysql_query("SELECT *,UNIX_TIMESTAMP(`date`) AS `date` FROM `attempts` WHERE `defender`='{$verdediger->login}' ORDER BY `date` DESC LIMIT 0,1");
                $lastattempt					= mysql_fetch_object($lastattempt1);
                echo "
                <?php
                $dbres       = mysql_query("SELECT *,UNIX_TIMESTAMP(`tijd`) AS `tijd`,0 FROM `[detective]`");
                while($delete = mysql_fetch_object($dbres)){
                $tijd             = $delete->tijd+$delete->uren*60*60-time();
                }
                $prijspuur = "7500";
                $prijspuur1 = number_format($prijspuur);
                print <<<ENDHTML
                <form method="POST">
                	<tr>
                		<td class="mainTxt" width="150">Bruker:</td>
                		<td class="mainTxt"><input type="text" name="naam" size="20"></td>
                	</tr>
                	<tr>
                		<td class="mainTxt">Timer:</td>
                		<td class="mainTxt">
                			<select size="1" name="uren">
                				<option value="1" selected>1</option>
                				<option value="2">2</option>
                				<option value="3">3</option>
                				<option value="4">4</option>
                			</select></td>
                	</tr>
                	<tr>
                		<td class="mainTxt" colspan="2" align="center">Koster: \$$prijspuur1,- per time.</td>
                	<tr>
                		<td class="mainTxt" align="right" colspan="2"><input style="width: 100" type="submit" value="Lei Detektiv!" name="submit1"></td>
                	</tr>
                </form>
                <tr><td>&nbsp;</td></tr>
                ENDHTML;
                if(isset($_POST['submit1']) && $_POST['naam'] != "" && $_POST['uren'] == 1 OR $_POST['uren'] == 2 OR $_POST['uren'] == 3 OR $_POST['uren'] == 4) {
                $naam2          = htmlspecialchars($_POST['naam']);
                $uren           = htmlspecialchars($_POST['uren']);
                $naam1		= mysql_query("SELECT * FROM `[users]` WHERE `login`='{$naam2}'");
                $naam		= mysql_fetch_object($naam1);
                $naamaantal	= mysql_num_rows($naam1);
                
                print "<font color=red>";
                if($naamaantal < 1){
                print "* Ugyldig bruker!";
                }
                elseif($uren*$prijspuur > $data->cash){
                print "* Du har ikke nok penger!.";
                }
                else{
                $geld	= round($uren*$prijspuur);
                $vind2	= round(4/$uren);
                $vind1	= rand(1,$vind2);
                if($vind1 == 1 && $naam->level <= 50) {
                $vind	= rand(900,$uren*60*60);
                }
                else{
                $vind        = 0;
                }
                
                mysql_query("INSERT INTO `[detective]` (`tijd`,`uren`,`zoeker`,`naam`,`status`,`vind`,`land`) values(NOW(),'$uren','{$data->login}','{$naam->login}','0','$vind','')");
                mysql_query("UPDATE `[users]` SET `cash`=`cash`-'$geld' WHERE `login`='{$data->login}'");
                print "Du leide en detektiv.";
                }
                
                print "</font>";
                }
                
                echo "</table>";
                echo "<table width=\"500\">";
                
                if(isset($_POST['wis']) && isset($_POST['id'])) {
                $id               = htmlspecialchars($_POST['id']);
                $dbres = mysql_query("SELECT * FROM `[detective]` WHERE `id`='$id' AND `zoeker`='{$data->login}'");
                $aantal = mysql_num_rows($dbres);
                if($aantal >= 1) {
                mysql_query("DELETE FROM `[detective]` WHERE `id`='$id' AND `zoeker`='{$data->login}'");
                print "<font color=red>* Du stoppet detektiven.</font>";
                } else
                echo "* Invalid id!";
                }
                
                
                print "	<tr><td colspan=\"2\"><form method=\"post\">";
                print "	<table width=\"100%\"><tr><td width=10>&nbsp;</td>  <td class=\"subTitle\" align=\"center\" width=185><i>Navn:</i></td>  <td class=\"subTitle\" align=\"center\" width=199><i>Tid igjen:</i></td>  <td class=\"subTitle\" align=\"center\" width=153><i>by:</i></td></tr>";
                
                
                $detectives2        = mysql_query("SELECT *,UNIX_TIMESTAMP(`tijd`) AS `tijd`,0 FROM `[detective]` WHERE `zoeker`='{$data->login}'");
                
                while($detectives = mysql_fetch_object($detectives2)) {
                	$tijd		= $detectives->tijd+$detectives->uren*60*60-time();
                	$tijd2		= $tijd-3600;
                	$tijd3		= date("H", "$tijd2");
                	$tijd1		= date("H:i:s", "$tijd2");
                	$zoeker		= mysql_query("SELECT * FROM `[users]` WHERE `login`='{$detectives->naam}'");
                	$zoeker		= mysql_fetch_object($zoeker);
                
                if($detectives->tijd + $detectives->vind < time() && $detectives->vind !=0){
                mysql_query("UPDATE `[detective]` SET `land`='{$zoeker->City}', `status`='1' WHERE `id`='{$detectives->id}'");
                }
                $deletetime		= round(time()-($detectives->tijd+(($detectives->uren*3600)+(7*3600))));
                if($deletetime >= 0) {
                mysql_query("DELETE FROM `[detective]` WHERE `id`='$detectives->id'");
                }
                
                if($tijd3 > $detectives->uren)
                $tijd1		= "Klarte ikke og finne brukeren";
                
                if($detectives->status == 1) {
                $tijd1          = "Funnet";
                $land		= "$detectives->land";
                } else {
                $land = "Searching";
                }
                
                print "<tr><td width=10><input type=\"radio\" name=\"id\" value=\"{$detectives->id}\"></td> <td class=\"mainTxt\" width=185><a href=\"profile.php?x={$detectives->naam}\">{$detectives->naam}</a></td>  <td class=\"mainTxt\"><b>{$tijd1}</b></td>  <td class=\"mainTxt\" width=153>{$land}</td></tr>";
                }
                print " </table><input type=\"submit\" value=\"fjern\" name=\"wis\"></form></td></tr>";
                
                
                ?>
                </table>
                
                
                </body>
                
                </html>

                And this is the line with the error:

                $dbres       = mysql_query("SELECT *,UNIX_TIMESTAMP(`tijd`) AS `tijd`,0 FROM `[detective]`");

                PS: I tried it to fix it many times, but i don't get i to work 🙁