darksniperx
-
Posts
113 -
Joined
-
Last visited
Never
Posts posted by darksniperx
-
-
Hello,
I run the query(stored procedure) in mssql query analyser , everything works and I get an output. When I run the same code in php and I do print_r, I get rownum => -1. Maybe I need to turn on some features in pear mdb2 so that I could see the results from running a stored procedure.
$qry = $mdb2->query("SET ANSI_NULLS ON; EXEC GetItems @item='1', @page=2");
print_r($qry); [rownum] => -1 [types] => Array ( ) [values] => Array ( )
-
Hrmm, is ANSI_WARNINGS set?
$mdb2->query("SET ANSI_NULLS ON;");
$mdb2->query("SET ANSI_WARNINGS ON;");
$mdb2->executeStoredProc("GetItems;", $items);
Maybe?
I got it to work.
Thank you!
$mdb2->query("SET ANSI_NULLS ON; EXEC GetItems @item='1', @page=2");
-
Oh yeah... I just remember that for some reason, GO has to be on it's own line.
You could try:
$sth =& $mdb2->func->executeStoredProc("SET ANSI_NULLS ON\nGO\n exec GetItems", $bindvars);
Gives the same error.
But I just noticed that you're using executeStoredProc. SET isn't a store procedure, so you should probably just run it in a normal query. Also, some interfaces don't allow multiple queries in one go, so MDB2 might be like that.
So, you could try:
$mdb2->query("SET ANSI_NULLS ON;");
$mdb2->executeStoredProc("GetItems;", $items);
I get the error which requests ansi_null to be turned on
[Native message: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.]
-
Try:
$sth =& $mdb2->func->executeStoredProc("SET ANSI_NULLS ON; GO exec GetItems", $bindvars);
Or maybe
$sth =& $mdb2->func->executeStoredProc("SET ANSI_NULLS ON; GO; exec GetItems", $bindvars);
Just tryed it, and I am getting the same issue.
Thank you!
-
Hi
I was just missing function include. I dont get that error once I have added the include.
-
$sth =& $mdb2->func->executeStoredProc("SET ANSI_NULLS ON go exec GetItems", $bindvars); if (PEAR::isError($sth)) { die("Error:" . $sth->getMessage(). ', ' . $sth->getDebugInfo()); }
I am getting the following error,
[Native code: 170] [Native message: Line 1: Incorrect syntax near 'go'.]
Searched everywhere, cant find a way to fix it.
-
What error does it give you?
Well it doesnt give me any error, I get a blank page. I have tryed to pinpoint the issue and I get the issue at this line
$sth=MDB2->prepare("exec
-
I have pear mdb2 module installed on my php sandbox.
I am trying to run a stored procedure and cant get it to work. I get a blank page. The stored procedure it self is fine, since I can use it in sql query analyser.
I have searched the net and found the following code.
<?php require_once 'MDB2.php'; $dsn = array( 'phptype' => 'mssql', 'username' => $_POST['user'], 'password' => $_POST['pass'], 'hostspec' => $_POST['host'], 'database' => $_POST['db'], ); $options = array( 'debug' => 2, 'portability' => MDB2_PORTABILITY_ALL, ); $mdb2 =& MDB2::connect($dsn, $options); if (PEAR::isError($mdb2)) { die($mdb2->getMessage(). ', ' . $mdb2->getDebugInfo()); } echo "Connected!"; $sth = $mdb2->prepare("exec getItem") or die($sth->getMessage(). ', ' . $sth->getDebugInfo()); $bindvars = array("id" => 'a123', "count" => 8, "location" => 'system'); $res=$mdb2->execute($sth,$bindvars)or die($res->getMessage(). ', ' . $res->getDebugInfo()); $result=$res->fetchRow()[0]; echo $result; ?>
I can connect to db without any issues, I just cant run the stored procedure.
Thank you!
-
I will delete by date then, I guess that is the easiest thing.
-
Why go through all the hassle?
hourlyupdate is the one where has tons of data being added to, and archiveUpdates is the one that users read to check their stats. my hourly update got too much records so its killing my db.
-
I have 2 tables in my database, hourlyUpdates and archiveUpdates. I would like to create a php script that would cut the data from hourlyUpdates table and append it to archiveUpdates table. The main question is how can I cut the data to be sure that i have removed only exactly what was select statment. For example, hourlyUpdates table has data a,b,c I append the data to archiveUpdates, by the time append has finished hourlyUpdates has a,b,c,d data. When I remove the data I need to be that I remove only what I have copied.
-
I am allready using that site and I am folowing their examples, but cant figure out where is the problem.
-
what would be the proper way of writing phpDocumentations.?
-
ah ok, thx
-
you got me confused?!? ???, you mean my where clause is not suppose to work, I have also tryed "not like ' ' ".
-
Firstly you're using C like a string by enclosing it in single quotes (')
You have two options
SELECT A , B, trim(C) FROM TableA WHERE trim(C) != ''
SELECT A , B, trim(C) as 'c' FROM TableA WHERE c != ''
I have fixed it by:
SELECT A , B, C FROM TableA WHERE trim(C) != ''
-
ok, that works, how would I put it inside php.
if($selectAll) {
$all = '';
}
else { $all = "WHERE trim© != ' ' "}
$sql = "
SELECT A , B, trim© FROM TableA
{$all}
";
exept I cannot get the single quotes to show up.
-
Dont know if I am in the right section, But I am trying to use phpDoc to generate documents. And phpdoc ignores my code.
<?php /** * Location Support Page * * Form that allows users to bypass validation * @author Dev Team <devteam@devteam> * @version $Id: byPass.php,v 1.0 2008/03/13 13:38:27 cellog Exp $; * @package byPass */ /** * Stores search results. * @var string * @name $result */ $result = ''; /** * @var string * @internal Stores sql connection for server A */ $connection = mysql_connect(); ?>
OUTPUT:
Description:
Location Support Page
Form that allows users to bypass validation
author: Dev Team <devteam@devteam>
version: $Id: byPass.php,v 1.0 2008/03/13 13:38:27 cellog Exp $;
php doc ignores all of my @var,@internal,@name,.. tags. Any ideas?
-
I would like to do a query that selects field a,b,c. Trims field c, and ignores the whole record if field c is empty.
something like this.
SELECT A , B, trim('C') FROM TableA WHERE C != ''
Any ideas on how to get the code work.
-
thx, I have just figured out what I did wrong, when I you said I was using mysql_queury twice, it took me while to notice, anyways I guess I was tired, thx again for the help!
-
the rest of my code doesn't work
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
and I have been using the $result = mysql_query(''); everywhere , and I never had a problem, just cant figure out why I have one now.
php.net provided the code with an example and never showed any errors
-
Query failed Resource id #18 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #18' at line 1
$result_a = mysql_query("SELECT * FROM authortoperson WHERE feed_id = '$feed_id' AND entry_id = 0 "); //test code if ($sql = mysql_query($result_a)) { // query was successfull. if (mysql_num_rows($result_a)) { // rows were found, fetch array and display result. } else { echo "No rows found"; } } else { echo "Query failed<br />$result_a<br />" . mysql_error() ."<br />"; }
give me the error message above, cant figure out why, any hints would be helpful!
-
I have fixed it by doing this "userInputs_"+id
-
thx, I should have found it myself.
mssql query analyser returns results, while php returns [rownum] => -1 ?
in Microsoft SQL - MSSQL
Posted
Update:
If i run a regular select * from table, I get results in php no problem.