GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Feb-2008, 11:09
Dench Dench is offline
New Member
 
Join Date: Feb 2008
Posts: 3
Dench is on a distinguished road

T_variable, improve my syntax!


Ok so here is my code in question:

PHP Code:

/* Check Username */   $result = mysql_query("SELECT * FROM login_table WHERE Username = '$_POST['Username']'");   $num_rows = mysql_num_rows($result);   if ($num_rows = 1)   {     echo "There is already a username with this name"   }   else   {     echo "This username is valid"   } 



and im gettin the dreaded unexpected T_variable, im 99% sure this is something to do with my syntax like a bracket of quote mark or something, the error occurs on the $result, any thoughts?
  #2  
Old 28-Feb-2008, 11:31
Dench Dench is offline
New Member
 
Join Date: Feb 2008
Posts: 3
Dench is on a distinguished road

Re: T_variable, improve my syntax!!


missed some semi-colons nvm!!
  #3  
Old 28-Feb-2008, 11:45
TreyAU21's Avatar
TreyAU21 TreyAU21 is offline
Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 116
TreyAU21 has a spectacular aura aboutTreyAU21 has a spectacular aura about

Re: T_variable, improve my syntax!!


There is another problem that I saw in your code too.

Code:
/* Check Username */ $result = mysql_query("SELECT * FROM login_table WHERE Username = '$_POST['Username']'"); $num_rows = mysql_num_rows($result); if ($num_rows = 1) { echo "There is already a username with this name" } else { echo "This username is valid" }

Besides the missing semicolons, you are also doing an assignment (NOT A COMPARISON) in your if statement. Every time that you run this code, you will enter that if statement because you aren't checking to see if $num_rows is equal to 1... you are SETTING $num_rows equal to 1.

Code:
// This is what you need if($num_rows == 1)
__________________
If practice makes perfect and nobody's perfect... why practice?

Homepage: http://www.treywhite.com
Blog: http://www.treywhite.com/blog.php
Web Design Company: http://www.ewebproductions.com
  #4  
Old 28-Feb-2008, 12:25
Dench Dench is offline
New Member
 
Join Date: Feb 2008
Posts: 3
Dench is on a distinguished road

Re: T_variable, improve my syntax!!


aye, i made a few mistakes, musn't have had my brain on!! its going ok now!!
 
 

Recent GIDBlogNARMY by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked Lists advice request promsan C Programming Language 74 23-May-2007 08:29
syntax errors in document coder MS Visual C++ / MFC Forum 0 11-Mar-2006 04:12
Winsock error when compiling FLTK 2.0 Projects mauriciorossi FLTK Forum 3 16-Aug-2005 10:18
Help with syntax errors PeteGallo C Programming Language 7 08-Aug-2005 20:30
C++ PhoneBook marita CPP / C++ Forum 46 12-Jun-2005 12:10

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:15.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.