Results 1 to 5 of 5

Thread: Problem with PHP/MySQL code [RESOLVED]

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    31

    Problem with PHP/MySQL code [RESOLVED]

    PHP Code:
    $user "myuser";
    $pw "mypw";
    $database="mydb";
    mysql_connect(localhost,$user,$pw);
    @
    mysql_select_db($database) or die("Unable to select database");
    $query "SELECT * from mytable";
    $result mysql_query($query);
    echo 
    'All countdown dates subject to change:<br>';
    echo 
    '<applet code="countdown.class" CODEBASE="http://www.mywebsite.com" width="203" height="21">'
    echo 
    '<param name="font" value=".$row['cfont'].">';
    echo 
    '<param name="year" value=".$row['cyear'].">'
    echo 
    '<param name="month" value=".$row['cmonth'].">'
    echo 
    '<param name="day" value=".$row['cday'].">';
    echo 
    '<param name="hour" value=".$row['chour'].">'
    echo 
    '<param name="timezone" value=".$row['ctimezone'].">';
    echo 
    '</applet><br><br>';
    mysql_close(); 
    I'm having trouble with this code. I'm trying to create a little php thing that takes what I have in my website and creates a bunch of countdowns. Can anyone help me? I don't know where I'm screwing up and since I got some good help last time I thought this would be a good spot to ask again.
    Last edited by Ataru Moroboshi; Sep 28th, 2007 at 08:34 PM.

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Problem with PHP/MySQL code

    Try this

    PHP Code:
    $user "myuser"
    $pw "mypw"
    $database="mydb"
    mysql_connect(localhost,$user,$pw); 
    @
    mysql_select_db($database) or die("Unable to select database"); 
    $query "SELECT * from mytable"
    $result mysql_query($query); 

    $row mysql_fetch_array($result); //line added

    echo 'All countdown dates subject to change:<br>'
    echo 
    '<applet code="countdown.class" CODEBASE="http://www.mywebsite.com" width="203" height="21">'
    echo 
    '<param name="font" value=".$row['cfont'].">'
    echo 
    '<param name="year" value=".$row['cyear'].">'
    echo 
    '<param name="month" value=".$row['cmonth'].">'
    echo 
    '<param name="day" value=".$row['cday'].">'
    echo 
    '<param name="hour" value=".$row['chour'].">'
    echo 
    '<param name="timezone" value=".$row['ctimezone'].">'
    echo 
    '</applet><br><br>'
    mysql_close(); 

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    31

    Re: Problem with PHP/MySQL code

    Hm...still doesn't work. I don't know what it is. I wonder if it's something wrong with the echos, maybe I didn't write the variables correctly. Should I get rid of the periods or something? Think it could be the $row variables?

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Problem with PHP/MySQL code

    put this anywhere in your code:

    echo mysql_error();
    My usual boring signature: Something

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    31

    Re: Problem with PHP/MySQL code

    Ah figured it out. The problem was in the echos. When doing it like the rows like that, you MUST use this method. '.$row['rowname'].'
    Doing that fixed it up just fine!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width