Coding Help Please

Started on the old forum in January 2011 · view the original in the archive · old links redirect here

15 replies · 640 views · started 15 years ago · 1 min read

3 participants
darkdesire Senior · 250 posts #1

this has been stressing me for days lol could anyone please tell me what i've done wrong? i'm trying to get a page to pm all members, the code im using follows...

<?php 
header("Cache-Control: no-cache, must-revalidate");
	include("config.inc.php");
header("Pragma: no-cache");
header("Content-type: text/vnd.wap.wml"); 
echo "<?xml version=\"1.0\"?>"; 
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; 
echo "<wml>"; 
$sqlthing = mysql_query("SELECT * FROM members WHERE username='$username'");
   $owner=(mysql_result($sqlthing,0,"owner"));
   $pmname=(mysql_result($sqlthing,0,"pmname"));
   $buddyname=(mysql_result($sqlthing,0,"buddyname"));

echo "<card id=\"card1\" title=\"$pmname Sent\">"; 
echo "<p align=\"center\">";

$Connect = mysql_connect("$server","$user","$pass");
mysql_select_db("$dbname");
$result=mysql_query("select * from members where username='$username' and session='$session'");
$number_of_rows = mysql_num_rows($result);
if ($number_of_rows>0)
{
	include("check.inc.php");
}
if ($ok>0)
{
	include("online.inc.php");

$date_sent = date('Y-m-d H:i:s');

	$from_username=$username;
	$has_it_been_read = "no";
    $pos=1;

$gbvalues="$pm_message";
	include("smilies.inc.php");

$max_results = 3000; 
$result9 = mysql_query("SELECT * FROM members ORDER by id asc LIMIT 0, $max_results"); 
 $username9=(mysql_result($result9,0,"username"));

$date_sent = date('Y-m-d H:i:s');
	$sql = "INSERT INTO privatemessage3 (to_username, from_username, date_sent, has_it_been_read, pm_message, spamfree) VALUES ('$username9','$from_username','$date_sent','no','$pm_message','$pos')";
$result = mysql_query($sql);

echo " PM Sent to All Staff<br/>";
echo "<a title=\"Enter\" href=\"pm.php?username=$username&session=$session\">Continue</a>";

        
        
        }
echo "</p>";
echo "</card>";
echo "</wml>";
?>

My problem is it only sends to one person and i cant work out how to get it to select every member, any help would be appreciated

Many thanks Jamie

:p:p:p

subzero Super moderator Fellow · 3,954 posts #2

'$username9'

You need to array this as this only will lookup 1 per send.

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

darkdesire Senior · 250 posts #3

thanks sub but thats the bit i dont see how to do, i dont understand why its only returning one name

:p:p:p

subzero Super moderator Fellow · 3,954 posts #4
$result = mysql_query("SELECT * FROM members ORDER by id"); 

if(mysql_num_rows($result) > 0) 
{ 
$username9 = 0; 
while ($row = mysql_fetch_array ($result, mysql_ASSOC)) 
{
$username9 = $row['to_username'] . ', ';
$date_sent = date('Y-m-d H:i:s');
	$sql = "INSERT INTO privatemessage3 (to_username, from_username, date_sent, has_it_been_read, pm_message, spamfree) VALUES ('$username9','$from_username','$date_sent','no','$pm_message','$pos')";
$result = mysql_query($sql);
}

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

darkdesire Senior · 250 posts #5

that just gives me a white page sub mate

:p:p:p

subzero Super moderator Fellow · 3,954 posts #6

. ', ';

take out

then place ; only

My error lol

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

darkdesire Senior · 250 posts #7

still the same mate, white page, validation says - end of document in prolog

:p:p:p

subzero Super moderator Fellow · 3,954 posts #8
$result = mysql_query("SELECT * FROM members ORDER by id"); 
if(mysql_num_rows($result) > 0) 
{ 
$username9 = 0; 
while ($row = mysql_fetch_array ($result, mysql_ASSOC)) 
{
$username9 = $row['to_username'] . ', ';
$date_sent = date('Y-m-d H:i:s');
	$sql = "INSERT INTO privatemessage3 (to_username, from_username, date_sent, has_it_been_read, pm_message, spamfree) VALUES ('$username9','$from_username','$date_sent','no','$pm_message','$pos')";
$count++; 
} 
echo "myResult=$count Emails Sent. Done."; 
}else{ 
echo "myResult=Email Submissions Failed."; 
}

Or

$result = mysql_query("SELECT * FROM members ORDER by id"); 
if(mysql_num_rows($result) > 0) 
{ 
$count = 0;
while ($row = mysql_fetch_array ($result, mysql_ASSOC)) 
{
$username9 = $row['to_username'] . ', ';
$date_sent = date('Y-m-d H:i:s');
	$sql = "INSERT INTO privatemessage3 (to_username, from_username, date_sent, has_it_been_read, pm_message, spamfree) VALUES ('$username9','$from_username','$date_sent','no','$pm_message','$pos')";
$count++; 
} 
echo "myResult=$count Emails Sent. Done."; 
}else{ 
echo "myResult=Email Submissions Failed."; 
}

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

darkdesire Senior · 250 posts #9

myResult=0 Emails Sent. Done. PM Sent to All Staff Continue

but nothing sent to anyone now mate

the coding youre trying mate looks more like php5, its a php4 scotspaul script im editing

:p:p:p

subzero Super moderator Fellow · 3,954 posts #10

oh ok i will think of a good plan then

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

subzero Super moderator Fellow · 3,954 posts #12

Give this a shot

$query="SELECT * FROM members ORDER by id";
$result=mysql_query($query);
$num=mysql_num_rows($result);

 $i=0;
        while ($i < $num) 
        {
$username9=mysql_result($result,$i,"to_username");

$date_sent = date('Y-m-d H:i:s');
$sql = "INSERT INTO privatemessage3 (to_username, from_username, date_sent, has_it_been_read, pm_message, spamfree) VALUES ('$username9','$from_username','$date_sent','no','$pm_message','$pos')";
$result = mysql_query($sql);

$i++;
                                
        }
}

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

darkdesire Senior · 250 posts #13

Sorted it thanks sub, Cheers for the help. the following works fine

$result9 = mysql_query("SELECT * FROM members ORDER by id asc"); 
if(mysql_num_rows($result9) > 0) 
{ 
$count = 0;
while ($row = mysql_fetch_array ($result9)) 
{
$username9 = $row['username'];
$date_sent = date('Y-m-d H:i:s');
	$sql = "INSERT INTO privatemessage3 (to_username, from_username, date_sent, has_it_been_read, pm_message, spamfree) VALUES ('$username9','$from_username','$date_sent','no','$pm_message','$pos')";
$result = mysql_query($sql);

}}

:p:p:p

subzero Super moderator Fellow · 3,954 posts #14

Always glad to help.

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

darkdesire Senior · 250 posts #15

youre a star mate, its the array bit i missed, cheers dude

:p:p:p

ori Lead · 512 posts #16

use while() to do it ill post my code its for a different script though but you will get the idea

///// NOTIFY ALL MEMBERS/////
else if ($mode == "notifyall" && IsHeadAdmin($uid))
{
$title = "Notify all members";
$maxlength = 255;
$m = $mode;
$input_title = "Message:";
$button = "Send";
$process = get_var("process");
if ($process == 1)
{
$var = get_var("var");
if (IllegalChars($var)) $msg = "<span class=\"error\"><img src=\"./images/error.gif\" alt=\"[x]\"/>Illegal chars found!</span><br/>";
else if (strlen($var) == 0) $msg = "<span class=\"error\"><img src=\"./images/error.gif\" alt=\"[x]\"/>Message cannot be blank!</span><br/>";
else
{
$query = query("*",members,"id != $uid AND banned = 'N' ORDER BY id");
if (mysql_num_rows($query) > 0)
{
while($row = mysql_fetch_array($query))
{
sendinbox($uid,$row['id'],"N","notice to all users",$var);
}
$msg = "<span class=\"ok\"><img src=\"./images/ok.gif\" alt=\"[ok]\"/>Message has been sent to all members!</span><br/>";
}
else $msg = "<span class=\"error\"><img src=\"./images/error.gif\" alt=\"[x]\"/>Unable to send message!</span><br/>";
}
}
$what = Array("msg","title","maxlength","size","m","input_title","var","input2","button");
$with = Array($msg,$title,$maxlength,"",$m,$input_title,$var,"",$button);
Template($what,$with,"admindialog");
exit();
}

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close