查看: 1180|回复: 11
|
PHP初学者求助区
[复制链接]
|
|
我是PHP初学者, 我的php问题如下:
<?php
}
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '999';
$conn = mysql_connect($dbhost, $dbuser, $dbpass)
or die ('Error connecting to mysql');
$dbname = 'mydb';
mysql_select_db($dbname);
echo "\n<BR>\n";
echo " test dbhost -->",($dbhost);
echo "\n<BR>\n";
echo " test display-->",($idlist); //$idlist = CRMID
echo "\n<BR>\n";
//get all fields for mail function
$sql1 = "select a.smownerid, a.setype, a.description, b.email1 from crmentity a, users b where crmid = '$idlist' and a.smownerid = b.id";
$result = $adb->query ($sql1);
//$result = mysql_query("select a.smownerid, a.setype, a.description, b.email1 from crmentity a, users b where crmid = '$idlist' and a.smownerid = b.id")
// or die("Invalid query: " . mysql_error());
echo " test sql1 -->",($sql1);
echo "\n<BR>\n";
echo " test result -->",$result;
?>
但成果$result不能显示出来, 是那里错了呢?
成果如下:
test dbhost -->localhost
test display-->1766;
test sql1 -->select a.smownerid, a.setype, a.description, b.email1 from crmentity a, users b INTO crmid = '1766;' and a.smownerid = b.id
test result -->
[ 本帖最后由 leng77 于 4-5-2007 02:47 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 4-5-2007 12:14 PM
|
显示全部楼层
怎么跟我一样糊涂了?
没有问题,怎么回答? |
|
|
|
|
|
|
|

楼主 |
发表于 4-5-2007 12:16 PM
|
显示全部楼层
回复 #2 hui_wooi 的帖子
哈哈你太快了
现在有了 |
|
|
|
|
|
|
|
发表于 4-5-2007 12:23 PM
|
显示全部楼层
原帖由 leng77 于 4-5-2007 12:16 PM 发表
哈哈你太快了
现在有了
看起来是你的$result没有mysql_query。 |
|
|
|
|
|
|
|
发表于 4-5-2007 01:46 PM
|
显示全部楼层
少了一个步骤。。。
你没有去索取你的 result。
看这里的例子:http://www.php.net/manual/en/ref.mysql.php |
|
|
|
|
|
|
|

楼主 |
发表于 4-5-2007 03:33 PM
|
显示全部楼层
我可以看到result 了
$sql1 = "select a.smownerid, a.setype, a.description, b.email1 from crmentity a, users b where crmid = '$idlist' and a.smownerid = b.id";
$result = $adb->query($sql1);
echo " test sql1 -->",($sql1);
echo "\n<BR>\n";
echo " test result -->",$result;
成果=
test sql1 -->select a.smownerid, a.setype, a.description, b.email1 from crmentity a, users b where crmid = '1766;' and a.smownerid = b.id
test result -->smownerid,setype,description,email1 94,Leads,"description of lead",test@mail.com
我现在要把资料寄出去, 可以直接用mail()的function吗?要如何把setype变成subject,description变成message,email1 变成 to?
试用fetch()不能
Fatal error: Call to undefined method ADORecordSet_mysql::fetch()
[ 本帖最后由 leng77 于 4-5-2007 03:49 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 4-5-2007 04:00 PM
|
显示全部楼层
$to = $result['email'];
以此类推
mail($to, $subject, $message, $headers); |
|
|
|
|
|
|
|

楼主 |
发表于 4-5-2007 05:28 PM
|
显示全部楼层
原帖由 hui_wooi 于 4-5-2007 04:00 PM 发表
$to = $result;
以此类推
mail($to, $subject, $message, $headers);
<?php
}
//get all fields for mail function
$sql1 = "select a.smownerid, a.setype, a.description, b.email1 from crmentity a, users b where crmid = '$idlist' and a.smownerid = b.id";
$result = $adb->query($sql1);
echo " test sql1 -->",($sql1);
echo "\n<BR>\n";
echo " test result1 -->",$result;
$to = $result['email1'];
$subject = $result['setype'];
$message = $result['description'];
//mail($to, $subject, $message, $headers);
echo "\n<BR>\n";
echo " test result to -->",($to);
?>
你的意示是这样吗? 我试了但result如下(有问题):-
test sql1 -->select a.smownerid, a.setype, a.description, b.email1 from crmentity a, users b where crmid = '1766;' and a.smownerid = b.id
test result1 -->smownerid,setype,description,email1 94,Leads,"test message",test@yahoo.com
Fatal error: Cannot use object of type ADORecordSet_mysql as array in C:\Program Files\CRM\modules\Users\massChangeStatus.php on line 198
请问什么是ADORecordSet? |
|
|
|
|
|
|
|
发表于 4-5-2007 06:22 PM
|
显示全部楼层
原帖由 leng77 于 4-5-2007 05:28 PM 发表
<?php
}
//get all fields for mail function
$sql1 = "select a.smownerid, a.setype, a.description, b.email1 from crmentity a, users b where crmid = '$idlist' and a.smownerid = b ...
方便的话,把整个code放上来。 |
|
|
|
|
|
|
|

楼主 |
发表于 7-5-2007 12:08 PM
|
显示全部楼层
原帖由 hui_wooi 于 4-5-2007 06:22 PM 发表
方便的话,把整个code放上来。
整个code?php code已经放上去了(如上),其他的是其他function,全部会很多很多哦
我现在试fetch:
while (list($smownerid, $setype, $description, $email1) = mysql_fetch_row($result)):
print "<tr>\n";
print "<td>$smownerid</td>\n<td>$setype</td>\n";
print "</tr>\n";
endwhile;
但成果是:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\Program Files\CRM\modules\Users\massChangeStatus.php on line 202
这是为甚么?请问php4跟 php5两个都可以用mysql_fetch_row()吗?
[ 本帖最后由 leng77 于 7-5-2007 02:34 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 7-5-2007 02:46 PM
|
显示全部楼层
你的 code 很怪很乱,可以把完整的放上来吗?从执行 sql 到你 send mail 就好,你上面的 code 没有 mysql_fetch_row,你最后一个 mysql_fetch_row 却又不完整。 |
|
|
|
|
|
|
|
发表于 9-5-2007 12:47 AM
|
显示全部楼层
回复 #10 leng77 的帖子
我想你应该不用LIST 吧。。。
while (list($smownerid, $setype, $description, $email1) = mysql_fetch_row($result)):
改成
$row = mysql_fetch_array($result);
echo $row['smownerid'];
试试可不可以ECHO 出来 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|