DanMerc
01-09-2005, 09:28 AM
OK, I have been trying this for hours and it just wont work for me.
To start off, I am trying to grab the value '93' from this table...
http://www.pixelradio.net/external/table.gif
The server I'm using is running MySQL 4.0.22-standard, with phpMyAdmin 2.6.0-pl3.
-----------------------------------------------------------------------
OK, the script has successfully made a connection to the server and selected the database.
I then try...
$count = mysql_query("SELECT value FROM values WHERE name='swearcount'") or die(mysql_error());
print($count);
... but get the error:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'values WHERE name='swearcount'' at line 1
I go into phpMyAdmin, manually run the query, and it works fine, and I click the "Create PHP Code" link, and it gives me...
Create PHP Code
SQL-query:
$sql = 'SELECT * FROM `values` LIMIT 0, 30';
I then try that...
$sql = 'SELECT value FROM `values` WHERE (`name` = ''swearcount'') LIMIT 0, 30';
$count = mysql_query($sql) or die(mysql_error());
print($count);
...and get:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/pr/public_html/sandbox/php/addswear2.php on line 3
So I then try:
$sql = 'SELECT value FROM `values` WHERE `name` = \'swearcount\'';
$count = mysql_query($sql) or die(mysql_error());
print($count);
...and get:
Resource id #3
------------------------------------------------------------------
Can anyone tell me what is wrong and what I should do to fix this? I never thought getting one number from a database could be so hard.
Thanks in advance,
Dan.
To start off, I am trying to grab the value '93' from this table...
http://www.pixelradio.net/external/table.gif
The server I'm using is running MySQL 4.0.22-standard, with phpMyAdmin 2.6.0-pl3.
-----------------------------------------------------------------------
OK, the script has successfully made a connection to the server and selected the database.
I then try...
$count = mysql_query("SELECT value FROM values WHERE name='swearcount'") or die(mysql_error());
print($count);
... but get the error:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'values WHERE name='swearcount'' at line 1
I go into phpMyAdmin, manually run the query, and it works fine, and I click the "Create PHP Code" link, and it gives me...
Create PHP Code
SQL-query:
$sql = 'SELECT * FROM `values` LIMIT 0, 30';
I then try that...
$sql = 'SELECT value FROM `values` WHERE (`name` = ''swearcount'') LIMIT 0, 30';
$count = mysql_query($sql) or die(mysql_error());
print($count);
...and get:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/pr/public_html/sandbox/php/addswear2.php on line 3
So I then try:
$sql = 'SELECT value FROM `values` WHERE `name` = \'swearcount\'';
$count = mysql_query($sql) or die(mysql_error());
print($count);
...and get:
Resource id #3
------------------------------------------------------------------
Can anyone tell me what is wrong and what I should do to fix this? I never thought getting one number from a database could be so hard.
Thanks in advance,
Dan.
