Log in

View Full Version : PHP Help



iUnknown
05-07-2008, 01:41 PM
Hello,


$get_spy_info = mysql_query("SELECT 'Radio_IP1', 'Radio_Port1', 'Radio_IP2', 'Radio_Port2', 'Radio_IP3', 'Radio_Port3', 'Radio_IP4', 'Radio_Port4', 'Radio_IP5', 'Radio_Port5' FROM radio_spy FROM 'radio_spy' WHERE id='1'") or die(mysql_error());

Could anyone tell me what's wrong with this sytax?

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 'FROM 'radio_spy' WHERE id='1'' at line 1

I'm attempting to make a script, for experience with PHP as well as use.

Fastest, best solution will get +rep. Thanks. :)

Dentafrice
05-07-2008, 02:02 PM
Because you specify FROM radio_spy twice..



<?php
$get_spy_info = mysql_query( "SELECT 'Radio_IP1', 'Radio_Port1', 'Radio_IP2', 'Radio_Port2', 'Radio_IP3', 'Radio_Port3', 'Radio_IP4', 'Radio_Port4', 'Radio_IP5', 'Radio_Port5' FROM radio_spy WHERE id='1'" ) or die( mysql_error() );
?>


If you are going to use that much, just use a wildcard * and then you can just pull it out of the array, without having to specify those, you are probably not working on a highly used application, so specifying what you are selecting isn't needed.

iUnknown
05-07-2008, 02:05 PM
Removed that, silly me, still same error :(

Edit: Ok done as you've said but still same error.

Dentafrice
05-07-2008, 02:05 PM
Whoops.



<?php
$get_spy_info = mysql_query("SELECT * FROM radio_spy WHERE id='1'") or die(mysql_error());
?>

iUnknown
05-07-2008, 02:07 PM
Whoops.



<?php
$get_spy_info = mysql_query("SELECT * FROM radio_spy WHERE id='1'") or die(mysql_error());
?>


Ah that works now. Thanks :D +rep

Want to hide these adverts? Register an account for free!