Jump to content

valadating database any idears please.


redarrow

Recommended Posts

why does this not work nothink happens any idears please cheers.

[code]

$query="select * from members_picture_uploads where id='$id'";
echo $query;
$result=mysql_query($query);

if(!mysql_num_rows($result)==1) {

echo"sorry only 1 picture per profile please use your update picture link on you members page";
exit;
}
[/code]

or

[code]



$query="select * from members_picture_uploads where id='$id'";
echo $query;
$result=mysql_query($query);
while($row=mysql_fetch_assoc($result) {

if(!$row["userfile_name"]==1) {


echo"sorry only 1 picture per profile please use your update picture link on you members page";
exit;
}
}

[/code]
Link to comment
Share on other sites

[quote]
[code]
$query="select * from members_picture_uploads where id='$id'";
echo $query;
$result=mysql_query($query);

if(!mysql_num_rows($result)==1) {

echo"sorry only 1 picture per profile please use your update picture link on you members page";
exit;
}
[/code]
[/quote]
If [a href=\"http://www.php.net/manual/en/ini.core.php#ini.register-globals\" target=\"_blank\"]register_globals[/a] is not on and you haven't assigned a value to $id using $_GET['id'] or $_POST['id'] etc, then you'll have to do that.
eg:
[code]
$id = $_GET['id']
[/code]
To help track down the problem you can add an "or die()" after the mysql_query call.
eg:
[code]
$result =  mysql_query($query) or die($query."<br />\n".mysql_error());
[/code]
If an error is displayed and your not able to figure out the problem, then post it here.

Also add the following to the top of your script(s) if you haven't done so already.
[code]
error_reporting(E_ALL);
[/code]
You'll see NOTICE errors that aren't usually displayed by default. They tend to help find problems that might otherwise be difficult to find.
Link to comment
Share on other sites

[!--quoteo(post=373457:date=May 13 2006, 07:57 AM:name=448191)--][div class=\'quotetop\']QUOTE(448191 @ May 13 2006, 07:57 AM) [snapback]373457[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Seems to me, looking at your script, nothing is SUPPOSED to happen.

Only if !mysql_num_rows($result)==1 something extra gets echoed. (Besides the query, which I assume IS being echoed.)
[/quote]


[!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--]
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.