Jump to content

Recommended Posts

Hey guys n gals...

 

At a bit of a loss on this one...

 

PHP on server is 5.1.6 (have 5.3 local) and PDO_MYSQL support is available on server...

 

Get no errors connecting to the mysql database but the queries I am running return nothing...

 

tried really simple stuff that I know data exists for in the correct tables like

<?php
$db	=	new PDO ('xxxxx');
$qry	=	"
	SELECT
		`user_id`,
		`username`,
		`user_level`
	FROM
		`users`
	WHERE
		`username`	=	:username
	";
$result	=	$this->prepare ( $qry );

$result->bindParam ( ':username' , 'toonmariner' , PDO::PARAM_STR );

$result->execute ();

var_dump ( $result->errorInfo());

echo '<br />Rowcount: ' . $result->rowCount () . '<br />';
if	(
$result->rowCount () == 0
)
{
echo 'NO rows.';
return NULL;
}
else
{
return $result->fetchAll (PDO::FETCH_ASSOC);
}
?>

On local machine I get the expected results
[code]
array(3) { [0]=>  string(5) "00000" [1]=>  NULL [2]=>  NULL }
Rowcount: 1
Array ( [0] => Array ( [user_id] => 1 [username] => toonmariner [user_level] => 1 ) ) 

 

where as live server yields...

array(1) { [0]=>  string(5) "00000" }
Rowcount: 0
NO rows.

 

Can any suggest some tasks to check what the hell is going on?

 

Database structure on dev and live server are identical as is the contents.

Link to comment
https://forums.phpfreaks.com/topic/181738-solved-pdo-help/
Share on other sites

yes...

 

as an update..

 

I call

 

var_dump ( debug_backtrace () );

 

after that code and when I run this on the server it prints out the array multiple times in a loop (which will explain why I'm getting mysql has gone away) but I end the script directly after the var_dump so I'm a little concerned as to why this cyclical call is going on...

Link to comment
https://forums.phpfreaks.com/topic/181738-solved-pdo-help/#findComment-958590
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.