Hi all, I just need some help with a code I have written. Sorry if it’s complete gibberish (only started learning 3 weeks ago!).
Basically, all I want to do is write a script that will query a MySQL database to find a user called ‘Robula UK’. This works so far and the browser outputs ‘Robula UK’ as it should.
I now want to output a message saying something like ‘Record not found’ only if ‘Robula UK’ is not found in that MySQL table.
So, a script that asks “Does this user exist? If so output ‘Robula UK’. If not then output ‘Record not found’”.
[code]<?php
$con = mysql_connect(“localhost”,“root”,“censored”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}
mysql_select_db(“forum”, $con);
$result = mysql_query(“SELECT * FROM phpbb_users WHERE username=‘Robula UK’”);
while($row = mysql_fetch_array($result))
if(mysql_fetch_array($result = ‘Robula UK’))
{
echo $row[‘username’];
}
else {echo(‘No’);}
mysql_close($con);
?>[/code]
You can see my attempts…I have tried and tried. But each time I fail to find the right syntax for this. Any help would be greatly appreciated.