Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    PHP Code:
    <?
    $id
    =$_GET['id'];
    if (!
    $id) exit;
    $sqlhost "localhost";
    $sqllogin "wplanet_db2user";
    $sqlpass "******";
    $sqldb "wplanet_db2";

    $db mysql_connect($sqlhost$sqllogin$sqlpass) or die("OOps!");
    mysql_select_db($sqldb$db);

    $result mysql_query ("SELECT id,name,from,email,website,tuts_writen FROM tutorials_writers
    WHERE id='
    $id'") or die('Error: ' mysql_error());
    $resrow mysql_fetch_array ($result);
    $id $resrow ['id'];
    $name $resrow ['name'];
    $from $resrow ['from'];
    $email $resrow ['email'];
    $website $resrow ['website'];
    $tuts_writen ['tuts_writen'];
    It gives me an SQL syntax Error... But I can't find the error :cry:
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  2.  

  3. #2
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    try
    PHP Code:
    $result mysql_query("SELECT `id`, `name`, `from`, `email`, `website`, `tuts_writen`
    FROM `tutorials_writers` WHERE id='
    $id'")
     or die(
    'Error: ' mysql_error()); 
    I also think that this; tuts_writen, might be wrongly spelt.
    JR

  4. #3
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    137 times
    written ?
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  5. #4
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    No, I named "writen" the cell
    But it doesnt affect becaue its the same as Sql
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  6. #5
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    What does the mysql_error() function return?
    JR

  7. #6
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    http://tutorials.webmastersplanet.co...riter.php?id=1
    Here is an example and the error is :
    Error: You have an error in your SQL syntax near 'from,email,website,tuts_writen from tutorials_writers where id='1'' at line 1
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  8. #7
    Member Black Vivi's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    75
    Member #
    1072
    you have to put backquotes arund the "from" part of the sql query (the first one, where all the columns to select from are), because thats part of a mysql function, and if that doesn't work, rename the column
    Download Firebird now!

  9. #8
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Yes, "from" is a reserved name.

    I do not suggest putting quotes around column names as it is against ANSI SQL standards. Instead, I suggest simply giving the column a different name.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  10. #9
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Most likely its your use of the reserved name "from" as a column name. Your MySql error message indicates the same, as it lists the first word in your query where it got confused. Rename the column.
    Another thing, it seems (of course I don't know this) you're extracting every, or close to every column in that particular table. You are also limiting your extraction to one row by using 'WHERE id=$id'. Why not just use the wildcard ' * ' instead to extract all columns from that row. then use the function EXTRACT($resrow); . Now your array is automatically broken into strings where each string is given the column name as identifier, with the associated row-data as value.

    i.e. <?php echo $name ?> gives the same output as <?php echo $resrow[name] ?>
    this gives you a lot less code to type (as long as you're only extracting one row from the table that is.
    S. Rosland

  11. #10
    Junior Member
    Join Date
    Aug 2003
    Posts
    1
    Member #
    2797
    uhmm... I'm not an admin or anything but can people please put spaces... it's really annoying when the table is that wide...


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:48 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com