New Person and PHP/MySQL
x-posted to
mysql
Hey there, finally decided to get on some communities that weren;t humour/music related, and this is my first stop.
I've only been using PHP and MySQL for a very short time now, though I find that for what I need it is fairly easy. However I am having a few issues with my current project which is effectively a large profile database. I'm using MySQL and PHP for this database, which is reliant upon user profiles, admin pages, and an online chat login.
I've tried a few forums and had some luck so far, but I'm still at a loss for a few things. My main concern currently is Unique Names for each profile. I was passed a small chunk of code, but when I attempted to integrate it in to my current DB insertion code, I just got errors flashing up. I am unsure if this is a PHP originated error, or if something is wrong within the MySQL coding. This is the code
Hey there, finally decided to get on some communities that weren;t humour/music related, and this is my first stop.
I've only been using PHP for a very short time now, though I find that for what I need it is fairly easy. However I am having a few issues with my current project which is effectively a large profile database. I'm using MySQL and PHP for this database, which is reliant upon user profiles, admin pages, and an online chat login.
I've tried a few forums and had some luck so far, but I'm still at a loss for a few things. My main concern currently is Unique Names for each profile. I was passed a small chunk of code, but when I attempted to integrate it in to my current DB insertion code, I just got errors flashing up. I am unsure if this is a PHP originated error, or if something is wrong within the MySQL coding. This is the code
mysql_connect(localhost,$username,$passw ord);
@mysql_select_db($database) or die( "Unable to select database");
$sql="SELECT count(id) FROM characters WHERE cname='$cname'";
$results=mysql_query($sql);
if (mysql_num_rows($results)>0){
echo "
There has been an error submitting your profile. That name has already been taken. Please press back in your browser and choose a new name
";
}
else if (mysql_num_rows($results)=0){
Insertion Code
} endif;
mysql_close();
Again, I'm new at PHP and MySQL both, so what the actual issue is, I dont know entirely.
I also wonder if the count(id) in $sql="SELECT count(id) FROM characters WHERE cname='$cname'"; has anything to do with it, as I suspect it may be refering to the field id, which I do not have in my database.
Any help is appreciated, even if to tell me that it is not a PHP issue and to not post this on this community *grins*
mysqlHey there, finally decided to get on some communities that weren;t humour/music related, and this is my first stop.
I've only been using PHP and MySQL for a very short time now, though I find that for what I need it is fairly easy. However I am having a few issues with my current project which is effectively a large profile database. I'm using MySQL and PHP for this database, which is reliant upon user profiles, admin pages, and an online chat login.
I've tried a few forums and had some luck so far, but I'm still at a loss for a few things. My main concern currently is Unique Names for each profile. I was passed a small chunk of code, but when I attempted to integrate it in to my current DB insertion code, I just got errors flashing up. I am unsure if this is a PHP originated error, or if something is wrong within the MySQL coding. This is the code
Hey there, finally decided to get on some communities that weren;t humour/music related, and this is my first stop.
I've only been using PHP for a very short time now, though I find that for what I need it is fairly easy. However I am having a few issues with my current project which is effectively a large profile database. I'm using MySQL and PHP for this database, which is reliant upon user profiles, admin pages, and an online chat login.
I've tried a few forums and had some luck so far, but I'm still at a loss for a few things. My main concern currently is Unique Names for each profile. I was passed a small chunk of code, but when I attempted to integrate it in to my current DB insertion code, I just got errors flashing up. I am unsure if this is a PHP originated error, or if something is wrong within the MySQL coding. This is the code
mysql_connect(localhost,$username,$passw
@mysql_select_db($database) or die( "Unable to select database");
$sql="SELECT count(id) FROM characters WHERE cname='$cname'";
$results=mysql_query($sql);
if (mysql_num_rows($results)>0){
echo "
There has been an error submitting your profile. That name has already been taken. Please press back in your browser and choose a new name
";
}
else if (mysql_num_rows($results)=0){
Insertion Code
} endif;
mysql_close();
Again, I'm new at PHP and MySQL both, so what the actual issue is, I dont know entirely.
I also wonder if the count(id) in $sql="SELECT count(id) FROM characters WHERE cname='$cname'"; has anything to do with it, as I suspect it may be refering to the field id, which I do not have in my database.
Any help is appreciated, even if to tell me that it is not a PHP issue and to not post this on this community *grins*