Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
0 user currently in Programming. | 3 guests |
Acmlm's Board - I2 Archive - Programming - Table screwing up PHP | | | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
Mercury Shyguy Level: 16 Posts: 1/88 EXP: 18132 For next: 2124 Since: 07-08-04 From: Hihihi. Since last post: 1 day Last activity: 1 day |
| ||
I have this script where you can click following button: < When you click that, this happens: if($submit3){ mysql_query("UPDATE users SET btemp = 0,btemp2 = 0, btemp3 = 0 WHERE id = '$loguserid' " ) or exit("Error 'flee @ btemp'" ); header("location: explore.php" ); This was working fine, you went to explore.php and could see the content. But than I added this in the PHP page: $inf=mysql_fetch_array(mysql_query("SELECT credits,lvl, exp, expnext FROM users WHERE id='$loguserid' LIMIT 1" )); print "< And it stopped working, it just showed a blank page. I found out the problem is because of the table, because if I leave out the table and just print the level, exp etc. it works . What's wrong? (edited by Mercury on 07-07-04 06:31 PM) |
|||
Darth Coby Vire Dacht je nou echt dat het over was? Dacht je nou echt dat ik gebroken was? Nee toch? Nou kijk eens goed op uit je ogen gast. zonder clic heb je geen kloten tjap... bitch Level: 55 Posts: 719/1371 EXP: 1240774 For next: 73415 Since: 03-15-04 From: Belgium Since last post: 2 days Last activity: 9 hours |
| ||
Woah, that's uhm. Not a way to do it. O_o You can't fetch an array like that, well not that I know of. Try this code, this one should work. $sql = mysql_query("SELECT credits, lvl, exp, expnext FROM users WHERE id = '$loguserid' LIMIT 1"); $inf = mysql_fetch_array($sql, MYSQL_ASSOC); print "< < < < < < < You FIRST store the MySQL query into the variable $sql and then you use MySQL fetch array on the variable $sql wich now contains the data that was grabbed from the DB. Then you select how to give out the information. That last past wasn't explained correctly, it just means the different ways of uhm.. Printing them, if you would take MYSQL_NUM then you'd have the use the column numbers, ASSOC means name and number and the other one I forgot. (Correct me if I'm wrong) EDIT: Err, you said it was the fault of the table? Try putting \s infront of the % signs and such and make sure that you also have \s before any quotation marks. (edited by Coby on 07-09-04 08:01 PM) (edited by Coby on 07-09-04 08:02 PM) (edited by Coby on 07-09-04 08:03 PM) (edited by Coby on 07-09-04 08:07 PM) |
|||
Mercury Shyguy Level: 16 Posts: 12/88 EXP: 18132 For next: 2124 Since: 07-08-04 From: Hihihi. Since last post: 1 day Last activity: 1 day |
| ||
There is nothing wrong with the fetching . I always do it like that, never have any problems. And it's the table indeed, because when I leave out the table, it works fine. I'll try and add the /'s . |
|||
Darth Coby Vire Dacht je nou echt dat het over was? Dacht je nou echt dat ik gebroken was? Nee toch? Nou kijk eens goed op uit je ogen gast. zonder clic heb je geen kloten tjap... bitch Level: 55 Posts: 722/1371 EXP: 1240774 For next: 73415 Since: 03-15-04 From: Belgium Since last post: 2 days Last activity: 9 hours |
| ||
Originally posted by Mercury \s :p And the fetching seems awfully wrong to me. :O But njeh, if it works then uhm.. Ok I guess. |
|||
Weasel Missionary in Peru Level: 34 Posts: 424/454 EXP: 236444 For next: 17207 Since: 03-15-04 From: Washington Since last post: 467 days Last activity: 339 days |
| ||
On the topic of fetching, Coby's way is nicer in the fact that it's bloody easier to read. Split it up into multiple lines. Imagine if someone else were to read your source code. They'd go mad. For example, read out loud $inf=mysql_fetch_array(etc....) compared to $inf = mysql_fetch_array( etc... ) Even something like using spaces between things helps a great deal with readability. Putting a fetch array and a query on separate lines helps a bit too. If you had an error and it said line 3, and all that crap was on line 3, you might have trouble figuring out where to put the fix. Debugging is easier when it's on a separate line. |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Programming - Table screwing up PHP | | | |