On submit,it runs my enter_num.php php script.
in the php script I have echo'd the variable that holds the unique number. It returns the correct number.
That number is then used in the SQL query.
I echo the SQL SELECT statement and the statement is good. I can copy and paste the echo'd text directly in phpMyAdmin and it returns 1 row as I expected.
Then I save field6 into variable $field_vi which is also a unique field. (note these are not the actual field names, I am just using them as the example here).
I echo'd $field_vi and it holds the value I expect.
My next query uses this value in the WHERE clause.
NOTE: I know I am open a connection, closing it and then opening it again for the second query. This may not be right, but at first I did not do this and it wasn't working, so I tried this way. It still didn't work.
I echo'd the $sql2 SELECT statement and it is correct...
I can copy and paste this select into phpMyAdmin and it returns a single row result with all my css fields.
I echo'd ALL the css variables and they all have the expected values.
But in my HTML, the values where I insert these variables in my html are ALL blank... The HTML page displays, but when I view page source,the css style statements are all there, but the variables are ALL blank.
Also before the <html> tag is the following WARNING (multiple times):
How do I get rid of the Warnings above from my html code AND why are my variables blank in the html code but populated just before that?<br />
<b>Warning</b>: mysql_result() [<a href='function.mysql-result'>function.mysql-result</a>]: Unable to jump to row 0 on MySQL result index 2 in <b>/home/content/b/b/e/servername/html/mysite/enter_num.php</b> on line <b>15</b><br />
Here is my php code.
Code: Select all
<?php
$enter_num=$_POST['ent_numb'];
$dbhost = 'my.hostlink.host.com';
$dbuser = 'dbusername';
$dbpass = 'mypassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'mydbname';
mysql_select_db($dbname);
$sql="SELECT uniq_number, field1, field2, field3, field4, field5, field6, field7 FROM mytablel WHERE uniq_number = '".$enter_num."'";
$result = mysql_query($sql);
$u_num = mysql_result($result, 0, "uniq_number");
$field_i = mysql_result($result, 0, "field1");
$field_ii = mysql_result($result, 0, "field2");
$field_iii = mysql_result($result, 0, "field3");
$field_iv = mysql_result($result, 0, "field4");
$field_v = mysql_result($result, 0, "field5");
$field_vi = mysql_result($result, 0, "field6");
$field_vii = mysql_result($result, 0, "field7");
mysql_close($conn);
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'mydbname';
mysql_select_db($dbname);
$sql2="SELECT image, image_repeat, image_pos, pad_left, pad_top, border, font_name, font_style, font_weight, font_size, letter_space, font_color, back_color FROM stile WHERE css_clas = '".$field_vi."'";
$result2 = mysql_query($sql2) or die(mysql_error());
$back_image = mysql_result($result2, 0, "image");
$bak_repeat = mysql_result($result2, 0, "image_repeat");
$back_pos = mysql_result($result2, 0, "image_pos");
$pad_lef = mysql_result($result2, 0, "pad_left");
$pad_topp = mysql_result($result2, 0, "pad_top");
$mem_border = mysql_result($result2, 0, "border");
$mem_font = mysql_result($result2, 0, "font_name");
$mem_font_sty = mysql_result($result2, 0, "font_style");
$mem_font_wt = mysql_result($result2, 0, "font_weight");
$mem_font_sz = mysql_result($result2, 0, "font_size");
$let_space = mysql_result($result2, 0, "letter_space");
$mem_font_col = mysql_result($result2, 0, "font_color");
$mem_bak_col = mysql_result($result2, 0, "back_color");
mysql_close($conn);
echo "<html>\n";
echo "<head>\n";
echo "<meta http-equiv=\"Content-Language\" content=\"en-us\">\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n";
echo "<title>My Title</title>\n";
echo "<meta name=\"description\" content=\"My description.\">\n";
echo "<style type=\"text/css\">\n";
echo " .mystyle{\n";
echo " background-image:url(\'".$back_image."\');\n";
echo " background-repeat: ".$back_repeat.";\n";
echo " background-position: ".$back_pos.";\n";
echo " padding-left: ".$pad_lef."px;\n";
echo " padding-top: ".$pad_topp."px;\n";
echo " border:".$mem_border.";\n";
echo " width:320px;\n";
echo " height:320px;\n";
echo " font-family:".$mem_font.";\n";
echo " font-style:".$mem_font_sty.";\n";
echo " font-weight:".$mem_font_wt.";\n";
echo " font-size:".$mem_font_sz.";\n";
echo " letter-spacing:".$let_space.";\n";
echo " color:".$mem_font_col.";\n";
echo " background-color:".$mem_bak_col.";\n";
//MORE HTML HERE.....
echo "</head>\n";
echo "</html>\n";
?>
Thank you.