Issue in PHP File Need Help

Discussion in 'PHP' started by Pathan, Sep 30, 2012.

  1. #1
    Hello,

    I was checking the error_log file and I noticed its having the following thing in it plenty of times.

    While checking the jso-themes.php on line number 61, we have the following coding.

    	$url = mysql_result($query, 0);
    PHP:
    Please suggest how to fix this.

    -Regards.
     
    Pathan, Sep 30, 2012 IP
  2. Nullifi3d

    Nullifi3d Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    what's the sql and the table data?
     
    Nullifi3d, Sep 30, 2012 IP
  3. Pathan

    Pathan Well-Known Member

    Messages:
    2,196
    Likes Received:
    218
    Best Answers:
    0
    Trophy Points:
    165
    #3
    Hi,

    Can you please further elaborate, I am unable to understand.
     
    Pathan, Sep 30, 2012 IP
  4. Nullifi3d

    Nullifi3d Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    what is the sql query ($query) and the table information from the database that you are quering.
     
    Nullifi3d, Sep 30, 2012 IP
  5. Pathan

    Pathan Well-Known Member

    Messages:
    2,196
    Likes Received:
    218
    Best Answers:
    0
    Trophy Points:
    165
    #5
    $query = mysql_query("SELECT DISTINCT(brand) FROM `urls` WHERE `type` = '{$_GET['type']}' ORDER BY `brand` ASC");
    	if(mysql_num_rows($query) > 0)
    	{
    		while($row = mysql_fetch_assoc($query))
    		{
    			$data[] = $row;
    		}
    	}
    PHP:
     
    Pathan, Sep 30, 2012 IP
  6. Nullifi3d

    Nullifi3d Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #6
    Before even attempting to figure out your code let me advise to NEVER place a session var inside an sql query. You need to escape and validate ALL variables that are used in sql queries to prevent code injection. Currently that sql is a huge security rick for your db/account, all shared accounts on the server and the entire server.

    Be sure to always check your connections/db selections/queries The below should print out the mysql error:
    if (!$query) {
         die('Query failure: ' . mysql_error());
    }
    PHP:
    You can also check your query by printing it out:
    print 'Query: ' . $query;
    PHP:
    Also take a look at using mysqli or PDO as mysql will soon be depreciated as a php fucntion.
     
    Nullifi3d, Sep 30, 2012 IP
  7. Drent123

    Drent123 Peon

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    There are many issue in php coding.
     
    Drent123, Oct 3, 2012 IP
  8. ankii

    ankii Member

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #8
    I can provide you solutions for PHP queries with the help of PHP experts.
     
    ankii, Oct 4, 2012 IP
  9. Nullifi3d

    Nullifi3d Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #9
    The above two posts are completely useless, thus making this post completely useless. :confused:
     
    Nullifi3d, Oct 4, 2012 IP
  10. Drent123

    Drent123 Peon

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    There are many issue in php that can not be resolve easily.
     
    Drent123, Oct 4, 2012 IP
  11. real_person

    real_person Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Many Errors?

    He had only 4 lines of programming!!

    Although if you see an error, you can tell him about, and the solution
     
    real_person, Oct 5, 2012 IP
  12. Nullifi3d

    Nullifi3d Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #12
    I believe his reply was more so random spam and wasn't directed at anyone specifically. Probably just trying to up his/her post count.
     
    Nullifi3d, Oct 5, 2012 IP