Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Posts posted by wildteen88

  1. Try:
    [code]$query = mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%{$search}%' AND $metode2 LIKE '%{$search2}%' ORDER BY '$sortby' ASC") or die("Unable to perform query: "  . mysql_error());[/code]

    I've never used the LIKE clause, so I'm going in blind sorry. With all the examples I've seen with the LIKE Clause they never use the ORDER BY clause prehaps you cant use it with LIKE.
  2. FYI magic_quotes_gpc doesn't affect variable names. The only thing it does affect is the value a variable contains such as if a variables value contains quotes magic_quotes_gpc eacapes any quotes.

    Now I think what you meant was register_globals rather than magic_quotes_gpc. register_globals should be off on both servers.

    I tried your script provded above on my local server running PHP 5.1.2 and $username doesn't affect $_SESSION['username'] at all.

    You must have something else that is set which is affecting variable names.

  3. Chnage this:[code]while ($row = @mysql_fetch_array($query))
    {
    $variable1=$row["DT_STRING"];
    $variable2=$row["ACCOUNT"];
    $variable3=$row["ACCOUNT_TYPE"];
    $variable4=$row["CLIENT_ID"];
    $variable5=$row["USER_ID"];
    //table layout for results

    print ("<tr>");
    print ("<td>$variable1</td>");
    print ("<td>$variable2</td>");
    print ("<td>$variable3</td>");
    print ("<td>$variable4</td>");
    print ("<td>$variable5</td>");
    print ("</tr>");
    }
    //below this is the function for no record!!
    if (!$variable1)
    {
    print ("$XX");
    }[/code]
    to:
    [code]// This is the proper way of checking whether your
    // MySQL query returned any results or not
    if(mysql_num_rows($query) >= 1)
    {
        while ($row = mysql_fetch_array($query))
        {
            $variable1=$row["DT_STRING"];
            $variable2=$row["ACCOUNT"];
            $variable3=$row["ACCOUNT_TYPE"];
            $variable4=$row["CLIENT_ID"];
            $variable5=$row["USER_ID"];
            //table layout for results

            print ("<tr>");
            print ("<td>$variable1</td>");
            print ("<td>$variable2</td>");
            print ("<td>$variable3</td>");
            print ("<td>$variable4</td>");
            print ("<td>$variable5</td>");
            print ("</tr>");
        }
    }
    else
    {
        "Your search criterea returned no results";
    }[/code]
    Also change your mysql query part of the code to this:
    [code]$query = mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' ORDER BY $sortby ASC") or die("Unable to perform query: "  . mysql_error());[/code]
  4. Change this:[code] <?php do { ?>
    <tr>
    <td>
    <?php echo $row_rstArtists['artist_name']; ?> </td>
    <td><a href="artists.php?artist=<?php echo $row_rstArtists['arist_pk']; ?>">View</a></td>
    </tr>
    <?php } while ($row_rstArtists = mysql_fetch_assoc($rstArtists)); ?>
    </table>[/code]to:[code] <?php while ($row_rstArtists = mysql_fetch_array($rstArtists)) { ?>
    <tr>
    <td>
    <?php echo $row_rstArtists['artist_name']; ?> </td>
    <td><a href="artists.php?artist=<?php echo $row_rstArtists['arist_pk']; ?>">View</a></td>
    </tr>
    <?php } ?>
    </table>[/code]
  5. You are using the assignment operater (=) rathar than the comparison operator (==). Also chnage your if statments to an if/elseif statment like so:
    [code]if ($hungry == '0') {
        $hunger = 'Starving';
    }
    elseif ($hungry == '1') {
        $hunger = 'Famished';
    }
    elseif ($hungry == '2') {
        $hunger = 'Hungry';
    }
    elseif ($hungry == '3') {
        $hunger = 'Unsatisfied';
    }
    elseif ($hungry == '4') {
        $hunger = 'Unsatisfied';
    }
    elseif ($hungry == '5') {
        $hunger = 'Satisfied';
    }
    elseif ($hungry = '6') {
        $hunger = 'Full';
    }
    elseif ($hungry = '7') {
        $hunger = 'Bloated';
    }[/code]
  6. Change this:
    [code]<td width="60"><b>DT_STRING</b></td>
    <td width="100"><b>ACCOUNT</b></td>
    <td width="30"><b>ACCOUNT_TYPE</b></td>
    <td width="150"><b>CLIENT_ID</b></td>
    <td width="150"><b>USER_ID</b></td>[/code]to the following:
    [code]<td width="60"><b><a href="?sortby=DT_STRING">DT_STRING</a></b></td>
    <td width="100"><b><a href="?sortby=ACCOUNT">ACCOUNT</a></b></td>
    <td width="30"><b><a href="?sortby=ACCOUNT_TYPE">ACCOUNT_TYPE</a></b></td>
    <td width="150"><b><a href="?sortby=CLIENT_ID">CLIENT_ID</a></b></td>
    <td width="150"><b><a href="?sortby=USER_ID">USER_ID</a></b></td>[/code]
    Now change the following code:
    [code]$query = mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%'"); [/code]to this:
    [code]//Create an array that sotes the possible values $_GET['sortby'] can hold
    $sortvalues = array("DT_STRING", "ACCOUNT", "ACCOUNT_TYPE", "CLIENT_ID", "USER_ID");

    //Check that $_GET['sortby'] is set and that the value it holds is in the $sortvalues array
    if(isset($_GET['sortby']) && in_array($_GET['sortby'], $sortvalues))
    {
        //set up the sortby variable that'll be used in the ORDER BY clause in the MySQL Query
        $sortby = $_GET['sortby'];
    }
    else
    {
        // This is the defualt value if $_GET['sortby'] is not set or the value it
        /// contains isn't in the $sortvalue array.
        $sortby = "DT_STRING";
    }

    $query = mysql_query("SELECT * FROM AUDIT WHERE $metode LIKE '%$search%' AND $metode2 LIKE '%$search2%' ORDER BY $sortby ASC");[/code]

    Hoep that helps.
  7. If you get a parse error in this format:
    Parse error: parse error, unexpected T_[x] in [path/of/script/here.php] on line [line numer here]

    Always check that you are ending your PHP lines with a semi-colon (;). Usually the line number gives it away. Do not look at the line PHP says the error is on as that is not where you missing the semi-colon, as the proper error is usually 1 or 2 lines above where the error occured. So if you get a parse error that says an unexpected T_VARIABLE on line 12 then look at lines 9 - 11 to make sure you are ending your lines correctly.
  8. So the above code you posted above works on your remote server but it doesnt work on your local server, which is installed on your PC?

    If so does your local server have register_globals turned on, if it does turn it off? and does your local server have [b]short_open_tag[/b] turned on too as [b]short_open_tag[/b] (<?) is set to off by defualt.
  9. To all your servers current configuration state use the phpinfo function. Create a new file called phpinfo.php and put this in it:
    [code]<?php

    p.hpinfo();
    //NOTE: make sure you remove the . between the p and the h

    ?>[/code]Now save your file and upload this file to your webshot. Now go to www.mysite.com/phpinfo.php

    You should no get a big page full of all configuration settinsg for your PHP setup and a few server sided settings too. Now scroll down and see if you can see a big header saying CURL if there is then you have cURL available to you.
  10. There is an error in your MySQL Query. Could you post your code here so we can see your query code.

    Also I would recommend you to put the following:
    [code]or die("MySQL Query Error: " . mysql_error());[/code] after mysql_query(... YOUR QUERY HERE ...)
    That way MySQL will tell you whats wrong with SQL Query.
  11. Are the files that you're adding
    [code]<? include ("access_control.php"); ?>[/code]to in the same folder as access_control.php?

    If they then that code is file, but if you add that code to a file that is not in the same folder as access_control.php you will need to do this instead:
    [code]<? include ("../access_control.php"); ?>[/code]

    NOTE you dont need to use that code in every file but only the pages you want password protected.
  12. Heres a tutorial [a href=\"http://www.phpit.net/article/create-bbcode-php/\" target=\"_blank\"]here[/a] for creating a BBCode function.

    Also when searching for BBCode tutorials make your search more specific such as: [a href=\"http://www.google.co.uk/search?num=100&hl=en&hs=Raq&safe=off&client=firefox-a&rls=org.mozilla:en-GB:official_s&q=PHP+BBcode+tutorial&spell=1\" target=\"_blank\"]PHP BBCode Tutorials[/a]. You'll get a much more better results rather than just searching for BBCode.

    If you want to learn how to create the buttons that insert the BBCode into a textarea then you might want to read [a href=\"http://www.thecodebehind.com/code/javascript/examples/javascript-textarea-buttons-bold-italic.aspx\" target=\"_blank\"]this[/a] tutorial.
  13. I would recommend you to rethink the way you use if/else statements, see the code below:
    [code]if($firstName){//----> CHECK input
            }
            else{
                $error.="Please, go back and fill out your first name<br>\n";//----> ERROR if no input
                }[/code]You can chnage that to this:
    [code]if(!$firstName) {
        $error.="Please, go back and fill out your first name<br>\n";//----> ERROR if no input
    }[/code]Use the [b]Not[/b] comparison operater (!) if you want to check that $firstname is not set. You can change all your if/else statments to the example provided above with the (not) ! operator.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.