coolbud012
11-27-2010, 03:12 PM
here is the announcement file for my website...its working when i myself enters particular number(s) .but when I select send to all it gives error :
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/username/public_html/testing/include/class_database.php on line 140
Warning: Invalid argument supplied for foreach() in /home/username/public_html/testing/admin/admin_announcements.php on line 22
here is the Php code for the file please help me I tried a lot to debug it..
{include file='admin_header.tpl'}
<h2>SMS Announcements</h2>
Use this form to compose an sms to be sent to every registered user on the sms website.
<br /><br />
{if $result == 1}
<div class='success'><img src='../images/success.gif' border='0' class='icon'> SMS has been sent to all users.</div>
{/if}
<form action="admin_announcements.php" method="post" name="sms_form" id="sms_form">
Enter Mobile Numbers below (comma, seperated):<br />
<textarea name="sms_mobiles" id="sms_mobiles" cols="50" rows="4"></textarea><br />
<input type="checkbox" name="sendtoall" id="sendtoall" value="1" /> <label for="sendtoall">Send to all users</label><br /><br />
Enter SMS Message Below:<br />
<textarea name="sms_message" id="sms_message" cols="50" rows="4" onkeyup="check_sms();"></textarea><br /><br />
<input type="text" name="chars_left" id="chars_left" readonly="1" disabled="disabled" value="320 chars left" style="width:100px; padding:5px; cursor:default;" /> <input type='submit' class='button' name="submitb" id="submitb" value="Send SMS">
<input type="hidden" name="task" value="sendsms" />
</form>
{literal}
<script>
function check_sms(){
document.sms_form.chars_left.value = 320 - document.sms_form.sms_message.value.length;
}
</script>
{/literal}
{include file='admin_footer.tpl'}
and here is the coding in for the error :
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/username/public_html/testing/include/class_database.php on line 140
here are the lines
// THIS METHOD FETCHES A ROW AS AN ASSOCIATIVE ARRAY
// INPUT: $result REPRESENTING A DATABASE QUERY RESULT RESOURCE
// OUTPUT: RETURNS AN ASSOCIATIVE ARRAY FOR A DATABASE ROW
function fetch_assoc($result) {
return mysql_fetch_assoc($result); // This is the 140th line
} // END fetch_assoc() METHOD
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/username/public_html/testing/include/class_database.php on line 140
Warning: Invalid argument supplied for foreach() in /home/username/public_html/testing/admin/admin_announcements.php on line 22
here is the Php code for the file please help me I tried a lot to debug it..
{include file='admin_header.tpl'}
<h2>SMS Announcements</h2>
Use this form to compose an sms to be sent to every registered user on the sms website.
<br /><br />
{if $result == 1}
<div class='success'><img src='../images/success.gif' border='0' class='icon'> SMS has been sent to all users.</div>
{/if}
<form action="admin_announcements.php" method="post" name="sms_form" id="sms_form">
Enter Mobile Numbers below (comma, seperated):<br />
<textarea name="sms_mobiles" id="sms_mobiles" cols="50" rows="4"></textarea><br />
<input type="checkbox" name="sendtoall" id="sendtoall" value="1" /> <label for="sendtoall">Send to all users</label><br /><br />
Enter SMS Message Below:<br />
<textarea name="sms_message" id="sms_message" cols="50" rows="4" onkeyup="check_sms();"></textarea><br /><br />
<input type="text" name="chars_left" id="chars_left" readonly="1" disabled="disabled" value="320 chars left" style="width:100px; padding:5px; cursor:default;" /> <input type='submit' class='button' name="submitb" id="submitb" value="Send SMS">
<input type="hidden" name="task" value="sendsms" />
</form>
{literal}
<script>
function check_sms(){
document.sms_form.chars_left.value = 320 - document.sms_form.sms_message.value.length;
}
</script>
{/literal}
{include file='admin_footer.tpl'}
and here is the coding in for the error :
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/username/public_html/testing/include/class_database.php on line 140
here are the lines
// THIS METHOD FETCHES A ROW AS AN ASSOCIATIVE ARRAY
// INPUT: $result REPRESENTING A DATABASE QUERY RESULT RESOURCE
// OUTPUT: RETURNS AN ASSOCIATIVE ARRAY FOR A DATABASE ROW
function fetch_assoc($result) {
return mysql_fetch_assoc($result); // This is the 140th line
} // END fetch_assoc() METHOD