User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,603 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,509 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3162 | Replies: 9
Reply
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Troubleshooting PHP and MySQL Stored Procedure Exec Problem

  #1  
Nov 7th, 2007
here is my stored procedure
  1. begin
  2. SELECT
  3. indexes.IndexID,
  4. languages.LanguageID,
  5. languages.LanguageName,
  6. indexes.OrderID,
  7. indexes.IndexName
  8. FROM
  9. indexes, languages
  10. WHERE indexes.LanguageID = languages.LanguageID AND languages.LanguageID = LANGUAGE
  11. ORDER BY indexes.OrderID ASC;
  12. end

here is my php code
  1. <?php
  2. $Server = "127.0.0.1";
  3. $Port = ":"."3306";
  4. $DataBase = "abc";
  5. $UserName = "def";
  6. $PassWord = "blabla";
  7. $Flags = "MYSQL_CLIENT_SSL";
  8. $Connection = mysql_connect($Server . $Port, $UserName, $PassWord, $Flags, 65536);
  9. if(!$Connection)
  10. {
  11. die("Could not connect to server : " . mysql_error());
  12. }
  13. else
  14. {
  15. mysql_select_db($DataBase,$Connection) or die("Could not connect to database");
  16. }
  17.  
  18. $TM = mysql_query("Call SP_Index($Language)",$Connection);
  19. while($TM_W = mysql_fetch_array($TM))
  20. {
  21. $i1++;
  22. print $TM_W[4];
  23. }
  24. ?>

so far everything works fine after calling second procedure.
.... doesnt show up anything... i got empty array
  1. <?php
  2. $Cat = mysql_query("Call SP_Category($Language)",$Connection);
  3. $Cat_N = mysql_num_rows($Cat);
  4.  
  5. while($Cat_W = mysql_fetch_array($Cat))
  6. {
  7. $i3++;
  8. print $Cat_W[4];
  9. }
  10. ?>
i closed and opened the connection and freed the previous array etc etc..
still nothing.. anyone has idea??

thanx in advance.
Last edited by fatihpiristine : Nov 7th, 2007 at 7:11 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: PHP and MySQL Stored Procedure Exec Problem

  #2  
Nov 8th, 2007
mysqli version.. doesnt work also...
  1. <?php
  2. $Server = "127.0.0.1";
  3. $DataBase = "teknober";
  4. $UserName = "root";
  5. $PassWord = "19741968";
  6. $Connection = mysqli_connect($Server, $UserName, $PassWord);
  7. if(!$Connection)
  8. {
  9. die("Could not connect to server : " . mysqli_error());
  10. }
  11. else
  12. {
  13. mysqli_select_db($Connection,$DataBase) or die("Could not connect to database");
  14. }
  15. ?>
  16. <?php
  17. print "Procedure #1<br>";
  18.  
  19. $TM = mysqli_query($Connection, "CALL mypro;");
  20. while($TM_W = mysqli_fetch_array($TM))
  21. {
  22. print $TM_W[2] . "<br>";
  23. }
  24.  
  25. ?>
  26. <?php
  27. print "<hr>";
  28. print "Procedure #2<br>";
  29. $TM = mysqli_autocommit($Connection,1);
  30. $TM = mysqli_query($Connection, "select * from news;");
  31. while($TM_W = mysqli_fetch_array($TM))
  32. {
  33. print $TM_W[2] . "<br>";
  34. }
  35. ?>
Reply With Quote  
Join Date: Sep 2007
Location: Buenos Aires
Posts: 30
Reputation: chmazur is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
chmazur's Avatar
chmazur chmazur is offline Offline
Light Poster

Re: PHP and MySQL Stored Procedure Exec Problem

  #3  
Nov 8th, 2007
On your store procedure.
...
...
where indexes.LanguageID = languages.LanguageID and languages.LanguageID = Language
...
...

what is Language? Did you try with $Languaje (?)

ch.-
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: PHP and MySQL Stored Procedure Exec Problem

  #4  
Nov 9th, 2007
language is the input parameter. i deleted it and still same. got error...
Last edited by fatihpiristine : Nov 9th, 2007 at 2:18 am.
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 72
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: PHP and MySQL Stored Procedure Exec Problem

  #5  
Nov 9th, 2007
did you set an out parameter on the procedure?
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: PHP and MySQL Stored Procedure Exec Problem

  #6  
Nov 9th, 2007
out parameter is not so important coz i need all values out. if i do something without using tables like:

declare in_x, in_y, out_z int;
select in_x * in_y = out_z;

select out_z;
end
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 72
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: PHP and MySQL Stored Procedure Exec Problem

  #7  
Nov 10th, 2007
i got a smiliar procedure to work on my server. i hope this helps.

here is the procedure:

CREATE PROCEDURE SP_Index (IN lang VARCHAR(255), OUT info BLOB) 
BEGIN
SELECT 
indexes.IndexID,
languages.LanguageID,
languages.LanguageName,
indexes.OrderID,
indexes.IndexName INTO info 
FROM indexes,languages 
WHERE indexes.LanguageID = languages.LanguageID AND languages.Language = lang 
ORDER BY indexes.OrderID ASC;
END

Here is the php:

<?php
$Server = "127.0.0.1";
$Port = ":"."3306";
$DataBase = "abc";
$UserName = "def";
$PassWord = "blabla";
$Flags = "MYSQL_CLIENT_SSL";
$Connection = mysql_connect($Server . $Port, $UserName, $PassWord, $Flags, 65536);
if(!$Connection)
{
    die("Could not connect to server : " . mysql_error());
}
else
{
    mysql_select_db($DataBase,$Connection) or die("Could not connect to database");
}

$TM = mysql_query("Call SP_Index($Language, @data)", $Connection);
$TM2 = mysql_query('SELECT @data');
while ($TM_W = mysql_fetch_array($TM2)) {

//DO WHAT YOU WANT

}
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: PHP and MySQL Stored Procedure Exec Problem

  #8  
Nov 10th, 2007
Did you test this? It doesn't work, i got it work somehow but.. when i call the second procedure..

still error.. no output
Last edited by fatihpiristine : Nov 10th, 2007 at 4:23 pm.
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 72
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: PHP and MySQL Stored Procedure Exec Problem

  #9  
Nov 10th, 2007
yes i did test it and it worked for me. did you set up your other procedure the same way? i have looked into procedures before but i have never really used them. i am going off basic knowledge and the mysql manual. i am just as lost as you are to why this is not working.
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: PHP and MySQL Stored Procedure Exec Problem

  #10  
Nov 10th, 2007
i m get more used to mssql procedures... i think i need to write kinda php module to execute multi stored procedures. thanks anyways
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 7:08 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC