PHP and MySQL Stored Procedure Exec Problem

Reply

Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

PHP and MySQL Stored Procedure Exec Problem

 
0
  #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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: PHP and MySQL Stored Procedure Exec Problem

 
0
  #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 Quick reply to this message  
Join Date: Sep 2007
Posts: 30
Reputation: chmazur is an unknown quantity at this point 
Solved Threads: 3
chmazur's Avatar
chmazur chmazur is offline Offline
Light Poster

Re: PHP and MySQL Stored Procedure Exec Problem

 
0
  #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 Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: PHP and MySQL Stored Procedure Exec Problem

 
0
  #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 Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: PHP and MySQL Stored Procedure Exec Problem

 
0
  #5
Nov 9th, 2007
did you set an out parameter on the procedure?
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: PHP and MySQL Stored Procedure Exec Problem

 
0
  #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 Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: PHP and MySQL Stored Procedure Exec Problem

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

here is the procedure:

  1. CREATE PROCEDURE SP_Index (IN lang VARCHAR(255), OUT info BLOB)
  2. BEGIN
  3. SELECT
  4. indexes.IndexID,
  5. languages.LanguageID,
  6. languages.LanguageName,
  7. indexes.OrderID,
  8. indexes.IndexName INTO info
  9. FROM indexes,languages
  10. WHERE indexes.LanguageID = languages.LanguageID AND languages.Language = lang
  11. ORDER BY indexes.OrderID ASC;
  12. END

Here is the php:

  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, @data)", $Connection);
  19. $TM2 = mysql_query('SELECT @data');
  20. while ($TM_W = mysql_fetch_array($TM2)) {
  21.  
  22. //DO WHAT YOU WANT
  23.  
  24. }
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: PHP and MySQL Stored Procedure Exec Problem

 
0
  #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 Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: PHP and MySQL Stored Procedure Exec Problem

 
0
  #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 Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: PHP and MySQL Stored Procedure Exec Problem

 
0
  #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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC