Jump to content

[SOLVED] any furthur code compression??


mforan

Recommended Posts

just wondering if there is any plausible way to make this code smaller, for when i add new columns to the database i have to change this file every time in 2 places:

 

$query = "INSERT INTO usersb SET fullname='$info[0]', email='$info[1]', cemail='$info[2]', username='$info[3]', password='$info[4]', squadname='$info[5]', lastclick='$info[6]', protection='$info[7]', rank='$info[8]', pop='$info[9]', tax='$info[10]', money='$info[11]', land='$info[12]', people='$info[13]', homes='$info[14]', farms='$info[15]', factories='$info[16]', hangars='$info[17]', turrets='$info[18]', repairbays='$info[19]', satellites='$info[20]', naval='$info[21]', art='$info[22]', lab='$info[23]', eb4='$info[24]', eb5='$info[25]', eb6='$info[26]', eb7='$info[27]', eb8='$info[28]', eb9='$info[29]', eb10='$info[30]', barren='$info[31]', createdate='$info[32]', freeland='$info[33]', alliance='$info[34]', logdate='$info[35]', networth='$info[36]', timer='$info[37]', messagecount='$info[38]', newscount='$info[39]', anewscount='$info[40]', t80='$info[41]', bmp='$info[42]', mi28='$info[43]', ah64='$info[44]', rah66='$info[45]', f16='$info[46]', f117='$info[47]', f22='$info[48]', b52='$info[49]', b2='$info[50]', icbm='$info[51]', bmls='$info[52]', nuke='$info[53]', custom1='$info[54]', u5='$info[55]', u6='$info[56]', u7='$info[57]', u8='$info[58]', u9='$info[59]', u10='$info[60]', t80a='$info[61]', bmpa='$info[62]', mi28a='$info[63]', ah64a='$info[64]', rah66a='$info[65]', f16a='$info[66]', f117a='$info[67]', f22a='$info[68]', b52a='$info[69]', b2a='$info[70]', icbma='$info[71]', bmlsa='$info[72]', nukea='$info[73]', custom1a='$info[74]', ua5='$info[75]', ua6='$info[76]', ua7='$info[77]', ua8='$info[78]', ua9='$info[79]', ua10='$info[80]', aid='$info[81]', power='$info[82]', banned='$info[83]', img='$info[84]', theme='$info[85]', premium='$info[86]', txn_id='$info[87]', admin='$info[88]', hacker='$info[89]', age='$info[90]', ros='$info[91]', breason='$info[92]', lastip='$info[93]', mteam='$info[94]', chatban='$info[95]', secret='$info[96]', vid='$info[97]', killedu='$info[98]', lostu='$info[99]', wonl='$info[100]', lostl='$info[101]', points='$info[102]', lostue='$info[103]', remail='$info[104]', killp='$info[105]', lasta='$info[106]', cuname='$info[107]', cuurl='$info[108]', cuap='$info[109]', cudp='$info[110]', country='$info[111]', rankno='$info[112]', reports='$info[113]', repip='$info[114]', whitel='$info[115]', ptrial='$info[116]', iemail='$info[117]', bank='$info[118]', bantimer='$info[119]' ON DUPLICATE KEY UPDATE fullname=VALUES(fullname), email=VALUES(email) , cemail=VALUES(cemail) , username=VALUES(username) , password=VALUES(password) , squadname=VALUES(squadname) , lastclick=VALUES(lastclick) , protection=VALUES(protection) , rank=VALUES(rank) , pop=VALUES(pop) , tax=VALUES(tax) , money=VALUES(money) , land=VALUES(land) , people=VALUES(people) , homes=VALUES(homes) , farms=VALUES(farms) , factories=VALUES(factories) , hangars=VALUES(hangars) , turrets=VALUES(turrets) , repairbays=VALUES(repairbays) , satellites=VALUES(satellites) , naval=VALUES(naval) , art=VALUES(art) , lab=VALUES(lab) , eb4=VALUES(eb4) , eb5=VALUES(eb5) , eb6=VALUES(eb6) , eb7=VALUES(eb7) , eb8=VALUES(eb8) , eb9=VALUES(eb9) , eb10=VALUES(eb10) , barren=VALUES(barren) , createdate=VALUES(createdate) , freeland=VALUES(freeland) , alliance=VALUES(alliance) , logdate=VALUES(logdate) , networth=VALUES(networth) , timer=VALUES(timer) , messagecount=VALUES(messagecount) , newscount=VALUES(newscount) , anewscount=VALUES(anewscount) , t80=VALUES(t80) , bmp=VALUES(bmp) , mi28=VALUES(mi28) , ah64=VALUES(ah64) , rah66=VALUES(rah66) , f16=VALUES(f16) , f117=VALUES(f117) , f22=VALUES(f22) , b52=VALUES(b52) , b2=VALUES(b2) , icbm=VALUES(icbm) , bmls=VALUES(bmls) , nuke=VALUES(nuke) , custom1=VALUES(custom1) , u5=VALUES(u5) , u6=VALUES(u6) , u7=VALUES(u7) , u8=VALUES(u8) , u9=VALUES(u9) , u10=VALUES(u10) , t80a=VALUES(t80a) , bmpa=VALUES(bmpa) , mi28a=VALUES(mi28a) , ah64a=VALUES(ah64a) , rah66a=VALUES(rah66a) , f16a=VALUES(f16a) , f117a=VALUES(f117a) , f22a=VALUES(f22a) , b52a=VALUES(b52a) , b2a=VALUES(b2a) , icbma=VALUES(icbma) , bmlsa=VALUES(bmlsa) , nukea=VALUES(nukea) , custom1a=VALUES(custom1a) , ua5=VALUES(ua5) , ua6=VALUES(ua6) , ua7=VALUES(ua7) , ua8=VALUES(ua8) , ua9=VALUES(ua9) , ua10=VALUES(ua10) , aid=VALUES(aid) , power=VALUES(power) , banned=VALUES(banned) , img=VALUES(img) , theme=VALUES(theme) , premium=VALUES(premium) , txn_id=VALUES(txn_id) , admin=VALUES(admin) , hacker=VALUES(hacker) , age=VALUES(age) , ros=VALUES(ros) , breason=VALUES(breason) , lastip=VALUES(lastip) ,  mteam=VALUES(mteam) , chatban=VALUES(chatban) , secret=VALUES(secret) , vid=VALUES(vid) , killedu=VALUES(killedu) , lostu=VALUES(lostu) , wonl=VALUES(wonl) , lostl=VALUES(lostl) , points=VALUES(points) , lostue=VALUES(lostue) , remail=VALUES(remail) , killp=VALUES(killp) , lasta=VALUES(lasta) , cuname=VALUES(cuname) , cuurl=VALUES(cuurl) , cuap=VALUES(cuap) , cudp=VALUES(cudp) , country=VALUES(country) , rankno=VALUES(rankno) , reports=VALUES(reports) , repip=VALUES(repip) , whitel=VALUES(whitel) , ptrial=VALUES(ptrial) , iemail=VALUES(iemail) , bank=VALUES(bank) , bantimer=VALUES(bantimer)";
mysql_query($query) or die("Error: ".mysql_error());

Link to comment
Share on other sites

<?php
$query = "SELECT * FROM your_table WHERE id= /*PUT ID HERE*/";
$result = mysql_query($query) or die(mysql_error());
$details = mysql_fetch_assoc($result);
foreach($details as $key => $value) {
echo "$key: $value<br />\n";
}

 

Instead of echoing the values you can serialize them into an array for storage

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.