sungpeng Posted April 2, 2009 Share Posted April 2, 2009 <?php if($_POST[action]=="Update") { include ("".$_SERVER['DOCUMENT_ROOT']."/housing/includes/config.php"); $indexnumber=$_GET[llid]; $user=$_POST[user]; $passwd=$_POST[pass]; echo $user; echo $passwd; echo $indexnumber; $check_result=0; $check_login=mysql_query("select * from users where email=$user and passwd=$passwd and llid=$indexnumber"); $check_result=mysql_num_rows($check_login); echo $check_result; }else{ ?> <html> <title>Upload an image to a database</title> <body> <h2>Update with new information</h2> <form name="form" enctype="multipart/form-data" method="post" action="<?php echo"$PHP_SELF?llid=$_GET[llid]"; ?>"> Please insert the images <input type='file' name='imagefile'><br> <br> USER : <input name="user"><br> PASSWORD : <input name="pass"><br> <input type="submit" name="action" value="Update"> </form> </body> </html> <?php } ?> Can help I keep having error message warning: mysql_num_row(): supplied argument is not a valid MySql result resource in insertphoto.php on line 17 Link to comment https://forums.phpfreaks.com/topic/152203-solved-error-message-mysql-num-rows/ Share on other sites More sharing options...
Yesideez Posted April 2, 2009 Share Posted April 2, 2009 Check your query as something is wrong with it. You using the field names correctly? I'd also advise on trying this: $check_login=mysql_query("SELECT * FROM `users` WHERE `email`='$user' AND `passwd`='$passwd' AND `llid`='$indexnumber'"); Link to comment https://forums.phpfreaks.com/topic/152203-solved-error-message-mysql-num-rows/#findComment-799258 Share on other sites More sharing options...
sungpeng Posted April 2, 2009 Author Share Posted April 2, 2009 Thank is working now.. Check with you yesideez why need to put '' ''' on top then it work. Sometime I don't put '''''' on top it also work? Link to comment https://forums.phpfreaks.com/topic/152203-solved-error-message-mysql-num-rows/#findComment-799262 Share on other sites More sharing options...
Yesideez Posted April 2, 2009 Share Posted April 2, 2009 Probably to do with spaces in the user input. Without surrounding the variables with single quotes MySQL wold parse variables with spaces differently. Example (I'll replace variable names with actual contents for sake of typing: Let's say we're searching for "car parts" in a table... SELECT * FROM table WHERE field=car parts MySQL would read "car" as the value and fall over with "parts" thinking you were sending it a command. Enclosing "car parts" in single quotes tells MySQL that everything inside them is the value: SELECT * FROM table WHERE field='car parts' Link to comment https://forums.phpfreaks.com/topic/152203-solved-error-message-mysql-num-rows/#findComment-799265 Share on other sites More sharing options...
sungpeng Posted April 2, 2009 Author Share Posted April 2, 2009 Thank a lot Link to comment https://forums.phpfreaks.com/topic/152203-solved-error-message-mysql-num-rows/#findComment-799268 Share on other sites More sharing options...
sungpeng Posted April 2, 2009 Author Share Posted April 2, 2009 hi Yesideez, ask you again, $image_path=$folder_path.$_FILES['images']['name]['$key']; $image_path=$folder_path.$_FILES['images']['name'][$key]; Why cannot write ['$key'] and must write [$key] bec I am puzzle sometime need to put """ sometime no need.. Link to comment https://forums.phpfreaks.com/topic/152203-solved-error-message-mysql-num-rows/#findComment-799273 Share on other sites More sharing options...
Yesideez Posted April 2, 2009 Share Posted April 2, 2009 The single quotes don't allow PHP to parse the contents so '$key' would literally be passing $key Try this as an example: $myvar=13; echo 'Variable: $myvar<br />'; echo "Variable: $myvar<br />"; That'll explain it better than I can with words. Link to comment https://forums.phpfreaks.com/topic/152203-solved-error-message-mysql-num-rows/#findComment-799277 Share on other sites More sharing options...
sungpeng Posted April 2, 2009 Author Share Posted April 2, 2009 Thank again Link to comment https://forums.phpfreaks.com/topic/152203-solved-error-message-mysql-num-rows/#findComment-799300 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.