944,111 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 11605
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 7th, 2007
0

PHP and MySQL Stored Procedure Exec Problem

Expand Post »
here is my stored procedure
sql Syntax (Toggle Plain Text)
  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
php Syntax (Toggle Plain Text)
  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
php Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 8th, 2007
0

Re: PHP and MySQL Stored Procedure Exec Problem

mysqli version.. doesnt work also...
php Syntax (Toggle Plain Text)
  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. ?>
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 8th, 2007
0

Re: PHP and MySQL Stored Procedure Exec Problem

On your store procedure.
...
...
where indexes.LanguageID = languages.LanguageID and languages.LanguageID = Language
...
...

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

ch.-
Reputation Points: 10
Solved Threads: 3
Light Poster
chmazur is offline Offline
30 posts
since Sep 2007
Nov 9th, 2007
0

Re: PHP and MySQL Stored Procedure Exec Problem

language is the input parameter. i deleted it and still same. got error...
Last edited by fatihpiristine; Nov 9th, 2007 at 2:18 am.
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 9th, 2007
0

Re: PHP and MySQL Stored Procedure Exec Problem

did you set an out parameter on the procedure?
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Nov 9th, 2007
0

Re: PHP and MySQL Stored Procedure Exec Problem

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
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 10th, 2007
0

Re: PHP and MySQL Stored Procedure Exec Problem

i got a smiliar procedure to work on my server. i hope this helps.

here is the procedure:

PHP Syntax (Toggle Plain Text)
  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:

PHP Syntax (Toggle Plain Text)
  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. }
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Nov 10th, 2007
0

Re: PHP and MySQL Stored Procedure Exec Problem

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.
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007
Nov 10th, 2007
0

Re: PHP and MySQL Stored Procedure Exec Problem

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.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Nov 10th, 2007
0

Re: PHP and MySQL Stored Procedure Exec Problem

i m get more used to mssql procedures... i think i need to write kinda php module to execute multi stored procedures. thanks anyways
Reputation Points: 6
Solved Threads: 19
Posting Whiz in Training
fatihpiristine is offline Offline
283 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Sending email fails
Next Thread in PHP Forum Timeline: Insert a new record in phpmyadmin db then display the record on new php page





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC