Jump to content
MakeWebGames

Welcome Message?


-BRAIDZ-

Recommended Posts

See this.

 

  • Have you tried it?
    • What went wrong?
    • Was there an error message?
    • Did you try and debug? If so, what did you do?

     

 

The forum software is adding spaces randomly in the code, so here's a mirror

I'm getting an error message

$db->query("UPDATE users SET mail_new=mail_new+1 WHERE userid=$userid"); on this line

Edited by -BRAIDZ-
Link to comment
Share on other sites

[MENTION=68406]-BRAIDZ-[/MENTION] what [MENTION=65371]sniko[/MENTION] is asking is the exact error which might show up something like this:

 

Undefined variable: user_location in C:\wamp\www\mypath\index.php on line 12

 

Then what did you try to do to fix the issue? Did you figure out what was causing the error? Did you use var_dump(); or anything else?

A simple search produced this. Have a proper read, don't just disregard the link.

An extract from the article.

 

Nobody enjoys the process of debugging their code. If you want to build killer web apps though, it’s vital that you understand the process thoroughly.

This article breaks down the fundamentals of debugging in PHP, helps you understand PHP’s error messages and introduces you to some useful tools to help make the process a little less painful.

Edited by Script47
Link to comment
Share on other sites

No you do not need to change UPDATE to INSERT, as UPDATE is for if a value is already in the database, by default it is going to be 0 so it already exsits in the database.

So all you need to change is the $userid to $i so your code should look like this:

$db->query("UPDATE `users` SET `mail_new` = `mail_new` +1 WHERE `userid` = $i");
Edited by adamhull
Link to comment
Share on other sites

No you do not need to change UPDATE to INSERT, as UPDATE is for if a value is already in the database, by default it is going to be 0 so it already exsits in the database.

So all you need to change is the $userid to $i so your code should look like this:

$db->query("UPDATE `users` SET `mail_new` = `mail_new` +1 WHERE `userid` = $i");

Thanks I understand now, will try it out shortly

Link to comment
Share on other sites

No you do not need to change UPDATE to INSERT, as UPDATE is for if a value is already in the database, by default it is going to be 0 so it already exsits in the database.

So all you need to change is the $userid to $i so your code should look like this:

$db->query("UPDATE `users` SET `mail_new` = `mail_new` +1 WHERE `userid` = $i");

QUERY ERROR: Unknown column 'mail_new' in 'field list'

Query was UPDATE `users` SET `mail_new` = `mail_new` +1 WHERE `userid` = 60

Link to comment
Share on other sites

Try:

$db->query("UPDATE `users` SET `new_mail` = `new_mail` +1 WHERE `userid` = $i");

The above wasn't named correctly, as far as I know. It's new_mail, not mail_new.

Thanks, that's what it was, working fine now, thank you everyone, appreciate it :)

Link to comment
Share on other sites

[MENTION=68406]-BRAIDZ-[/MENTION] Next time, dissect a few mod and try and help yourself first, that's how I learnt.

That's how I learned my limited PHP knowledge was dissecting existing mods, seeing the methods they used. Having come from C+ and Fortran and the Visual Basic/RealBasic language gave me a decent grounding into function and variables and all of that, but PHP's syntax is so much more particular its taken me awhile to grab it. Practicing and reading will make it perfect, in this case.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...