|
-
Sep 28th, 2007, 04:25 PM
#1
Thread Starter
Junior Member
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.
-
Sep 28th, 2007, 05:37 PM
#2
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();
-
Sep 28th, 2007, 05:51 PM
#3
Thread Starter
Junior Member
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?
-
Sep 28th, 2007, 07:39 PM
#4
Re: Problem with PHP/MySQL code
put this anywhere in your code:
echo mysql_error();
My usual boring signature: Something
-
Sep 28th, 2007, 08:33 PM
#5
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|