I can't see the $result
Posted: Tue Dec 18, 2007 12:03 pm
feyd | Please use
and I also wrote some PHP code as follows:[/syntax]
This proc when executed through SSH executes perfectly the result is something like this
yahoo.com 1024
aol.com 824
msn.com 253
...
xxx.xxx ###
showing a total of 5139 entries in the output
which is exactly what I want
now the part I am having difficulty with
I want to run this via my webpage
so i wrote this PHP code to display the result using the mysqli routines
this is my very first attempt at writing a stored procedure and using these mysqli routines so my mistake may be very simple but I looked and could not find it
the output gets modified in the PHP code a bit but should be displayed as follows(along with some connection info):
yahoo.com -- 1024 -- 1
aol.com -- 824 -- 2
msn.com -- 253 --3
...
xxx.xxx -- ### -- 5139
What i get is:
-- -- 1
-- -- 2
-- -- 3
...
-- -- 5139
This tells me that my PHP code is working and that the result set exists because it actually stops when I would expect it to but I just can't see the data
I write PHP code but I normally use the mysql routines so I am not sure if I am missing anything.
If you see my mistake or know what I am doing wrong please let me know
Current thought are: Does the stored procedure have to be somehow setup to actually produce output somewhere in the paramter fields
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Ok I created a stored procedure called emailbasecount but I do not have my original coding i simple listed it in the show create procedure function
[syntax="sql"]
DELIMITER //
BEGIN
SELECT COUNT(SUBSTRING(email_address,LOCATE('@',email_address)+1,LENGTH(email_address)-LOCATE('@',email_address)+1)) AS COUNT1 , SUBSTRING(email_address,LOCATE('@',email_address)+1,LENGTH(email_address)-LOCATE('@',email_address)+1) AS EMAILBASE FROM Email3 GROUP BY EMAILBASE;
END
DELIMITER ;
Code: Select all
/* create a connection object which is not connected */
$mysqli = mysqli_init();
/* set connection options */
//$mysqli->options(MYSQLI_INIT_COMMAND, "SET AUTOCOMMIT=0");
//$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
/* connect to server */
$mysqli->real_connect($dbhost, $db_login, $db_password,$db_base);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf ("Connection: %s\n.", $mysqli->host_info);
$query ="call emailbasecount;";
$stmt = mysqli_prepare($mysqli, $query);
mysqli_stmt_execute($stmt);
//mysqli_stmt_close($stmt);
echo "<BR>";
$result = mysqli_store_result($mysqli);
echo $result;
while ($row = mysqli_fetch_row($result)) {
echo $row;
$counts = $row[0];
$base= $row[1];
$i++;
echo $base." ====> ".$counts." ====> ".$i."<BR>";
}
$mysqli->close();yahoo.com 1024
aol.com 824
msn.com 253
...
xxx.xxx ###
showing a total of 5139 entries in the output
which is exactly what I want
now the part I am having difficulty with
I want to run this via my webpage
so i wrote this PHP code to display the result using the mysqli routines
this is my very first attempt at writing a stored procedure and using these mysqli routines so my mistake may be very simple but I looked and could not find it
the output gets modified in the PHP code a bit but should be displayed as follows(along with some connection info):
yahoo.com -- 1024 -- 1
aol.com -- 824 -- 2
msn.com -- 253 --3
...
xxx.xxx -- ### -- 5139
What i get is:
-- -- 1
-- -- 2
-- -- 3
...
-- -- 5139
This tells me that my PHP code is working and that the result set exists because it actually stops when I would expect it to but I just can't see the data
I write PHP code but I normally use the mysql routines so I am not sure if I am missing anything.
If you see my mistake or know what I am doing wrong please let me know
Current thought are: Does the stored procedure have to be somehow setup to actually produce output somewhere in the paramter fields
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]