hi, made a plain simple function to retrieve some data from a table but it screws up .. here's what i got
<--- header.php flie --->
echo data(tick);
echo mysql_error();
<--- config file --->
function data($option) {
$result = mysql_query("SELECT * FROM cw_data WHERE option='$option'");
$row = mysql_fetch_array($result);
$value = $row["value"];
return $value;
}
I did everything ok, db connection etc but this is what i get:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site99/fst/var/www/html/cw/cw/config_data.php on line 11
You have an error in your SQL syntax near 'option='tick'' at line 1 - Server Status:
thx in advancethat is because "option" is a reserved word in mysql. you have to change it to something else.<--- header.php flie --->
echo data(tick);
echo mysql_error();
<--- config file --->
function data($option) {
$result = mysql_query("SELECT * FROM `cw_data` WHERE `option`='$option'");
$row = mysql_fetch_array($result);
$value = $row["value"];
return $value;
}
That would probably be the best way but putting the `'s before it might work too.the ` do nothing what-so-ever. it is becasue he is using a mysql reserved word.Sorry scoutt, heh, once agian you prove me wrong... I used to come here alot but I forgot my username, I am back and more advanced with php/mysql...cool, glad to have ya back and more experienced mask person Oh and I really prefer for the beginners of mySQL to go to scotts site (<!-- m --><a class="postlink" href="http://snippetlibrary.com">http://snippetlibrary.com</a><!-- m -->) it doesnt have alot but what it does have on mysql was very useful to me when I knew nothing. Also, me and a friend are almost finished with PHPToolBox.com it allready has a lot of content.
<--- header.php flie --->
echo data(tick);
echo mysql_error();
<--- config file --->
function data($option) {
$result = mysql_query("SELECT * FROM cw_data WHERE option='$option'");
$row = mysql_fetch_array($result);
$value = $row["value"];
return $value;
}
I did everything ok, db connection etc but this is what i get:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site99/fst/var/www/html/cw/cw/config_data.php on line 11
You have an error in your SQL syntax near 'option='tick'' at line 1 - Server Status:
thx in advancethat is because "option" is a reserved word in mysql. you have to change it to something else.<--- header.php flie --->
echo data(tick);
echo mysql_error();
<--- config file --->
function data($option) {
$result = mysql_query("SELECT * FROM `cw_data` WHERE `option`='$option'");
$row = mysql_fetch_array($result);
$value = $row["value"];
return $value;
}
That would probably be the best way but putting the `'s before it might work too.the ` do nothing what-so-ever. it is becasue he is using a mysql reserved word.Sorry scoutt, heh, once agian you prove me wrong... I used to come here alot but I forgot my username, I am back and more advanced with php/mysql...cool, glad to have ya back and more experienced mask person Oh and I really prefer for the beginners of mySQL to go to scotts site (<!-- m --><a class="postlink" href="http://snippetlibrary.com">http://snippetlibrary.com</a><!-- m -->) it doesnt have alot but what it does have on mysql was very useful to me when I knew nothing. Also, me and a friend are almost finished with PHPToolBox.com it allready has a lot of content.