Page 1 of 1
Nothing Appears
Posted: Fri Jan 03, 2003 3:59 pm
by weenoid
Hi, I am quite new to SQL and I am currently just playing around with a few codes. The code below is one that I have written and i've checked that the databases are set up correctly and everything's fine. The problem is that when I open the page nothing appears. This is the code:
<?php
$sql = "connect [localhost]";
$result = $sql = "list_tables [exemu_files]";
$i = 0;
while ($i < $sql = "num_rows [$result]") {
$tb_names[$i] = $sql = "tablename [$result, $i]";
echo $tb_names[$i] . "
";
$i++;
}
?>
Any ideas as to what could be wrong? Any help would be much appreciated.
Posted: Wed Jan 08, 2003 11:41 am
by DaiWelsh
Hmm, seems like pretty much everything is wrong with it to me, in fact might you have done a search and replace on "mysql_" with "$mysql = " at some point because that would at leats make it look half familiar.
I am not in a position to test it but something like
<?php
mysql_connect (localhost);
$result = mysql_list_tables (exemu_files);
$i = 0;
while ($i < mysql_num_rows [$result]) {
$tb_names[$i] = mysql_tablename [$result, $i];
echo $tb_names[$i] . "< b r >";
$i++;
}
might at least be closer to what you are trying to do?
HTH,
Dai
Posted: Wed Jan 08, 2003 11:52 am
by BDKR
Hmm, seems like pretty much everything is wrong with it to me, in fact might you have done a search and replace on "mysql_" with "$mysql = " at some point because that would at leats make it look half familiar.
Lol !!!!!!
Be nice. At least he gave it a try which is a lot better than "write this for me".
Cheers,
BDKR
Posted: Wed Jan 08, 2003 3:28 pm
by DaiWelsh
Oops was me harsh? <slap>

Posted: Thu Jan 09, 2003 1:54 am
by DaZZleD
teehee
Posted: Thu Jan 09, 2003 2:53 am
by twigletmac
DaiWelsh wrote:because that would at least make it look half familiar

It was an interesting try and definitely better than saying 'write me some code'.
weenoid - the likely reason that nothing happened when you wrote the code is because you put the attempted function calls into quotes and used square brackets instead of parenthesis to add the arguments. This meant that PHP considered them strings and not function calls. The following should begin to show results ($user and $pass should be substituted by your username and password for the MySQL database - the default is 'root' and nothing for the password):
Code: Select all
<?php
@mysql_connect('localhost', $user, $pass) or die(mysql_error());
@$result = mysql_list_tables('exemu_files') or die(mysql_error());
while ($row = mysql_fetch_row($result)) {
$tb_names[] = $row[0];
echo $row[0].'<br />';
}
?>
You should probably also read up on the MySQL functions available in PHP and how to use them:
http://www.php.net/manual/en/ref.mysql.php
Mac