Can't find the bug...

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
rwhite35
New php-forum User
New php-forum User
Posts: 13
Joined: Thu Sep 27, 2012 10:55 am

Wed Jan 30, 2013 8:53 pm

Couple things to look at. Your PNS_DB looks like a constant, is it? If so, when you put it in quotes, you have assigned $dbName a string "PNS_DB". If PNS_DB is in fact a constant, I would just change the following

Code: Select all

$select = mysql_select_db(PNS_DB,$dbConn);
Next I would consider migrating to prepared statements using either mysqli or PDO. It looks like from this code that PNS only requires the connection $dbConn. You could make that connection like so

Code: Select all

     $dbConn = new mysqli(DB_HOST,DB_UNAME,DB_UPWORD,DB_NAME);
     if ($dbConn->connect_errno){
    	$mes = urlencode("Failed ".$dbConn->connect_error);
       	header("Location: $error.php?err=$mes");
       	exit();
     }
Then a query

Code: Select all

     $result=$dbConn->query("SELECT user_name FROM users");
Then output

Code: Select all

  while ($row = $result->fetch_assoc()) {
     echo "This user name is ".$row['user_name'];
  }
$dbConn->close();
ref: http://www.php.net/manual/en/book.mysqli.php

Finally, in some setups, the script and API both have to be owned by the same process. For example, on Linux, both script and API need to be owned by apache:apache. You would change the script and API ownership with the chown command from the command line.

admin# chown apache:apache Master.php
admin# chown apache:apache PNSLib.php

Hopefully that gives you some new leads to follow.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests