Search:  

 
 
   All ForumsHot TopicsGallery






how-to block ads


 
Forums » Tech and Talk » OS and Software » Webmasters and Developers » PHP MySQL while Loop
Search Topic:
Uniqs:
54
Share Topic:
RSS topic:
toggle:
flat / full
normal / watch
Posting:
Post a:
Post a:
Hosting Domain »
« HTML "alt" tag  
AuthorAll Replies


cdog
Boo
Premium
join:2001-10-11
Chicago, IL
clubs:

reply to justin
Re: PHP MySQL while Loop

said by justin See Profile:
Ths stupd forum was protecting us all from your long lines blowing the right margin, if you kept them to 80 columns or less, it would look just as you wanted it to.

ahhhh ok

p.s. I got it to work... thanks guys appreciate it
--
If what ya got is perfect and you always want better. Happiness will never come. - [Have Some Fun] -


justin
Australian
join:1999-05-28
Brooklyn, NY
reply to Ken Sohryu
Ths stupd forum was protecting us all from your long lines blowing the right margin, if you kept them to 80 columns or less, it would look just as you wanted it to.


Ken Sohryu
Darkest Days

join:2001-01-07
Chicago, IL


1 edit
reply to cdog
while_debug.zip 1,070 bytes
(while_debug.php)
The link to the source code you posted didn't work, so I had to wing it in writing up some basic error checking tools. I hope they help you out a bit.

edit: Stupid forum screwed up my beautiful code formatting, so I've attached the actual script.

// I basically threw in some basic diagnostic displays.
// Had no choice since the link to your complete source code
// wasn't working. Anyway, this should help you track down
// your problem. Hopefully.

error_reporting( E_ALL );

// GET SUPER ADMIN
$z_getsuper = mysql_query( "SELECT * FROM members WHERE mem_level = '5'" ) or die( mysql_e
*rror() );

// Loop through results.
while( $row = mysql_fetch_array( $z_getsuper ) )
{
// Comment this if() statement out or delete it when finished debugging.
if( $row['mem_id'] == 0 )
{
// Output all fields of "faulty" record for troubleshooting.
echo '<p>Error: An ID number of <strong>0</strong> was detected.</p>';

rsort( $row, SORT_NUMERIC );

$i = ( count( $row ) - 1 );

do
{
echo '<p>' . $row[$1] . '</p>';
}
while( $i-- );

die();
}

$z_super_id = $row['mem_id'];

// Construct SQL query separately. Easier to read.
$sql ="INSERT INTO mb_mod_alert SET
mb_mod_alert_receive_id = '$z_super_id',
mb_mod_alert_sender_id = '$l_id',
mb_mod_alert_preset = '$preset',
mb_mod_alert_reason = '$reason',
mb_mod_alert_msg = '$alert_msg',
mb_mod_alert_date = '$rightnow',
mb_mod_alert_status = 'new'";

// Send message to Super Admins.
$sendalertsuper = mysql_query( $sql );

// If message insertion fails, kill script and display debugging info.
// Comment out or delete when finished debugging.
if( mysql_affected_rows() <= 0 )
{
echo '<p><strong>NOTICE:</strong> Could not insert new record into database.</p>';

// If there was an SQL error, we'll display it.
if( mysql_error() )
{
echo '<p><strong>MySQL Error:</strong>' . mysql_error() . '</p>';
}

echo '<p><strong>Your SQL Query:</strong> <span style="color: #696;">' . $sql . '</span></
*p>';

die();
}
}

(*) WARNING 2 long line(s) split

--
» I am surrendering to the Gravity and the unknown.

» Catch me, heal me, lift me back up to the sun.

» I choose to live.

A Perfect Circle - Gravity


WalkGood
Checkin Out Your Desk
Premium
join:2002-12-28
Patchogue, NY

reply to cdog
Are u sure you are retrieving the CORRECT 3 super-admins in the first query?

Maybe you could break it into 2 parts. First fetch all the super-admins into an array. As a temporary debugging aide then in a separate loop go thru the array and display what's in that array.

Second part, in a separate loop go thru the array and do the insert.


cdog
Boo
Premium
join:2001-10-11
Chicago, IL
clubs:


1 edit
Hey I have a question I AM STUMPED. I am setting up a message board on my website and I have an alert admins section. Well in the forum I have "Super Admins" which have control over the whole site and every forum. Also I have board admins which just moderate what board they are assigned to.

"If someone hits "Hey Mods" like we have here at dslr it sends out an alert to the moderators of THAT forum and to the super mods.

Here are my 2 while loops:
// GET SUPER ADMIN
$z_getsuper = mysql_query("SELECT * FROM members WHERE mem_level = '5'");
while ($row = mysql_fetch_array($z_getsuper)) {
$z_super_id = $row['mem_id'];
// SEND MESSAGE TO SUPER ADMINS
$sendalertsuper = mysql_query("INSERT INTO mb_mod_alert SET
mb_mod_alert_receive_id = '$z_super_id',
mb_mod_alert_sender_id = '$l_id',
mb_mod_alert_preset = '$preset',
mb_mod_alert_reason = '$reason',
mb_mod_alert_msg = '$alert_msg',
mb_mod_alert_date = '$rightnow',
mb_mod_alert_status = 'new'");
}
Here is the problem... I have 3 super admins in my database, each have their own unique id set by mysql(auto_increment)

When the information gets entered into the database it works fine for one admin inserting his id, but then the other two it inserts and id of "0" as their member id.

it's counting there is 3 mods because it is inserting 3 rows in the table, but why is it only entering ONE user with his member ID???

I'm so confused

full code here : »www.pastebin.com/28435
Forums » Tech and Talk » OS and Software » Webmasters and DevelopersHosting Domain »
« HTML "alt" tag  


Tuesday, 01-Dec 19:57:50 Terms of Use | Privacy Policy | Hosting by www.nac.net - DSL,Hosting & Co-lo | feedback | contact
over 10 years online! © 1999-2009 dslreports.com.republican-creole
page compression OFF
Most commented news this week
· [121] Comcast Releasing Promised Usage Meter
· [67] Baltimore To Ban Lazy Cable Installs
· [55] Broadband Killed The Game Console
· [46] Rogers Unveils The ISP Dream Model
· [39] Rural Carriers Quickly Embracing Fiber
· [35] Charter Exits Chapter 11
· [33] AT&T Top Lobbyist Cicconi Has His Feelings Hurt
· [29] ACTA: Global Three Strikes
· [29] Latest Consumer Reports Survey Not Kind To AT&T
· [24] Midcontinent Socked With Easement Lawsuit
Most people now reading
· IMG 1.7 (IMG Updates and Discussion) [Verizon FIOS TV]
· [Internet] Gaming problem for "Heroes of Newerth" ( New bell Upd [Bell Canada]
· Ooma changing features [VOIP Tech Chat]
· [Phish] email from CDC "personal vaccination profile" [Spam, Scam and Phishbusters]
· Windows 7 boot manager editing questions [Microsoft Help]
· [Newsgroups] Newzleech down? [Filesharing Software]
· Am I the only one that loves to work in IT? [No, I Will Not Fix Your #@$!! Computer]
· Heating - my dad gave me this advice... [Home Repair & Improvement]
· Considering Leaving Vonage, who should I Consider? [VOIP Tech Chat]
· Limitations of the U-Verse HD experience (for families) [AT&T U-verse]