Announcement

Collapse
No announcement yet.

MySQL driving me crazy - a server issue?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DavidAllen
    replied
    Originally posted by MortimerJazz View Post
    You Sir are an absolute legend - not to mention a life saver.

    And you're just up the road in Amersham!

    Thanks so much for all your help!
    No Problem - anytime. I know how frustrating minor mistakes can be

    Leave a comment:


  • MortimerJazz
    replied
    You Sir are an absolute legend - not to mention a life saver.

    And you're just up the road in Amersham!

    Thanks so much for all your help!

    Leave a comment:


  • DavidAllen
    replied
    you missed the $result line
    so you get
    PHP Code:
    $result=mysql_query($recent_sql);
    while (
    $row mysql_fetch_array($result)) {
     
    $type=$row['type'];  //or whatever else you want to do for each row in the result

    Last edited by DavidAllen; 28-02-2008, 00:33.

    Leave a comment:


  • MortimerJazz
    replied
    Ok, I've got rid of the error message which suggests that the query's now running through fine.

    I've got one last question then I promise I'll leave you alone!

    I'm trying to use a while loop to cycle through the database and populate various variables.

    This is the entire code:

    PHP Code:
    $recent_sql "SELECT type, price, description, hire, age, adults, requirements, overnight, picture, dim, gallerypics FROM range WHERE type='$choice'";


    while (
    $recent mysql_fetch_array($recent_sql)){
    $type=$recent['type']; 

    Now the wierd thing is that without changing the MySQL call, suddenly I'm getting error messages again saying that it's not a valid resource.

    I dont' get it ...

    Leave a comment:


  • MortimerJazz
    replied
    Hang on, I think I might have it!

    Leave a comment:


  • MortimerJazz
    replied
    So frustrating:

    Code:
    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/bounce6/public_html/inf.php on line 37
    Thank you very much for your time

    I've gone through testing everything.

    The script connects to the database, it finds the database ... and there's definitely a column called type in the table.

    Leave a comment:


  • DavidAllen
    replied
    I don't get what $link_id is ... could that have anything to do with it?
    we cross posted - yes - get rid of it

    Leave a comment:


  • DavidAllen
    replied
    that line should be ok now
    that has put the SQL Server into a variable called recent_sql
    Now need to do the actual call
    so
    $result=mysql_query($recent_sql);;
    should give the data from the query into an object called $result
    to get from the $result object holing all the data to individual rows we need the next line
    $row = mysql_fetch_row($result);
    which leaves us pointing at the first row and can access the fields in that row like :
    echo $row['price'];
    Only difference is that the $link_id optional paremeter has been removed from the mysql_query call - I use $link_id as the return from the module that does the database connection - you don't need it

    Leave a comment:


  • MortimerJazz
    replied
    I don't get what $link_id is ... could that have anything to do with it?

    Leave a comment:


  • MortimerJazz
    replied
    I'm sorry to be a pain.

    I've now got my query looking like this:


    PHP Code:
    $recent_sql "SELECT type, price, description, hire, age, adults, requirements, overnight, picture, dim, gallerypics FROM range WHERE type='".$choice."'"
    ... but still no luck

    Leave a comment:


  • DavidAllen
    replied
    OK sorry - thought you hadn't used my original code
    just need to use $recent_sql="SELECT etc as above" ie don't need mysql_query - that is done on the line below $result=
    Last edited by DavidAllen; 27-02-2008, 23:56.

    Leave a comment:


  • MortimerJazz
    replied
    Yup - I just don't get it :frown:

    PHP Code:
    $recent_sql mysql_query("SELECT
                                type, 
                                price,
                                description, 
                                hire, 
                                age, 
                                adults, 
                                requirements, 
                                overnight, 
                                picture, 
                                dim, 
                                gallerypics
                                  FROM range 
                                WHERE type='"
    .$choice."'");


    $result mysql_query($recent_sql$link_id) or die('Query failed: ' mysql_error().'<br>'.$query);
    $row mysql_fetch_row($result) or die(mysql_error()); 

    Leave a comment:


  • DavidAllen
    replied
    did you get the quote marks right - single double .$choice.double single double ?

    Leave a comment:


  • MortimerJazz
    replied
    Still no luck I'm afraid.

    I'm just getting "Query Failed:" without any further explanation now

    Leave a comment:


  • DavidAllen
    replied
    Ah ok i see
    try mysql_query("SELECT id, blah, blah, etc FROM range WHERE type = '".$choice."'")

    trouble was where clause looked like - where type=castle rather than what you wanted which is WHERE type='castle'
    Last edited by DavidAllen; 27-02-2008, 23:39.

    Leave a comment:

Working...
X