Jump to content

T_VARIABLE error


ueon

Recommended Posts

for some reason, I'm receiving a T_VARIABLE error with the following code on line 20

 

<?php

include 'connect.php';

// Extracting Data
$sql = "SELECT css_file, js_file, div_file, table_file
	FROM stageone
	WHERE id = '1'";
$result = mysql_query ($sql) or die (mysql_error());
list ($css_num, $js_num, $div_num, $table_num) = mysql_fetch_row($result); 

$int_val1 = 0;
$int_val2 = 0;
$int_val3 = 0;
$int_val4 = 0;

// create css variables
do
{
$css_file$int_val1 = $_POST["css_name$int_val1"];
echo "<link rel='stylesheet' href='$css_file$int_val1' type='text/css'>\n";

$int_val1++;
}
while ($int_val1 != $css_num);	

// create js variables
do
{
$js_file$int_val2 = $_POST["js_name$int_val2"];
echo "<script language='JavaScript' src='$js_file$int_val2' type='text/javascript'></script>\n";

$int_val2++;
}
while ($int_val2 != $js_num);	

?>

Link to comment
https://forums.phpfreaks.com/topic/106170-t_variable-error/
Share on other sites

for some reason, I'm receiving a T_VARIABLE error with the following code on line 20

 

<?php

include 'connect.php';

// Extracting Data
$sql = "SELECT css_file, js_file, div_file, table_file
	FROM stageone
	WHERE id = '1'";
$result = mysql_query ($sql) or die (mysql_error());
list ($css_num, $js_num, $div_num, $table_num) = mysql_fetch_row($result); 

$int_val1 = 0;
$int_val2 = 0;
$int_val3 = 0;
$int_val4 = 0;

// create css variables
do
{
$css_file$int_val1 = $_POST["css_name$int_val1"];
echo "<link rel='stylesheet' href='$css_file$int_val1' type='text/css'>\n";

$int_val1++;
}
while ($int_val1 != $css_num);	

// create js variables
do
{
$js_file$int_val2 = $_POST["js_name$int_val2"];
echo "<script language='JavaScript' src='$js_file$int_val2' type='text/javascript'></script>\n";

$int_val2++;
}
while ($int_val2 != $js_num);	

?>

 

When you have 2 variables together as you do on two occasions ($sj_file$int_val2), put a . in between them.

Link to comment
https://forums.phpfreaks.com/topic/106170-t_variable-error/#findComment-544201
Share on other sites

change

do
{
$css_file$int_val1 = $_POST["css_name$int_val1"];
echo "<link rel='stylesheet' href='$css_file$int_val1' type='text/css'>\n";

$int_val1++;
}
while ($int_val1 != $css_num);	

to

do
{
$css_file = $_POST["css_name$int_val1"];
echo "<link rel='stylesheet' href='$css_file' type='text/css'>\n";

$int_val1++;
}
while ($int_val1 != $css_num);	

Link to comment
https://forums.phpfreaks.com/topic/106170-t_variable-error/#findComment-544218
Share on other sites

here you go

 

<?php

include 'connect.php';

// Extracting Data
$sql = "SELECT css_file, js_file, div_file, table_file
	FROM stageone
	WHERE id = '1'";
$result = mysql_query ($sql) or die (mysql_error());
list ($css_num, $js_num, $div_num, $table_num) = mysql_fetch_row($result); 

$int_val1 = 0;
$int_val2 = 0;
$int_val3 = 0;
$int_val4 = 0;

// create css variables


do
{
$css_file.$int_val1 = $_POST["css_name$int_val1"];
echo "<link rel='stylesheet' href='$css_file$int_val1' type='text/css'>\n";

$int_val1++;
}
while ($int_val1 != $css_num);	

// create js variables
do
{
$js_file.$int_val2 = $_POST["js_name$int_val2"];
echo "<script language='JavaScript' src='$js_file$int_val2' type='text/javascript'></script>\n";

$int_val2++;
}
while ($int_val2 != $js_num);	

?>

Link to comment
https://forums.phpfreaks.com/topic/106170-t_variable-error/#findComment-544231
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.