Jump to content

getting a string!!


i8grand

Recommended Posts

I am trying to insert an 81 character length string into my website from my database!  I have stored the string in a table and am trying to insert each character into individual cells in a 9 x 9 grid.  I have the following code but think I am doing something stupid, can anyone help!?

 

<?php

 

$puzzle = $_REQUEST["thisPuzzle"];

 

$dbQuery = "SELECT * FROM puzzlelevel, puzzle ".

"WHERE puzzlelevel.id = puzzle.levelId AND puzzlelevel.id = $puzzle";

$result = mysql_query($dbQuery,$db);

$dbRow = mysql_fetch_array($result);

 

/*$puzzlelevelid = $dbRow[0];

$puzzlelevel = $dbRow[1];

$puzzleid = $dbRow[2];

$solution = $dbRow[3];*/

$startGrid = $dbRow[4];

//levelid = dbRow[5];

 

?>

 

<script type="text/javascript">

 

var startGrid="<?php$startGrid?>";

 

</script>

 

<div id="puzzle">

 

<table class="table">

<tr>

<td width="45" height="45"><script>document.write(startGrid.charAt(0));</script></td>

 

 

the last line is the first of the cells!  thisPuzzle is called from the previous page and does work,  the problem lies when i try to call the startGrid field from my puzzle table and then try to get the first chracter from this and insert it into the first cell.  I am trying to create a sudoku puzzle!

 

Am I doing something stupid!? Any help would be brilliant, thank you

Link to comment
https://forums.phpfreaks.com/topic/196243-getting-a-string/
Share on other sites

This:

 

var startGrid="<?php$startGrid?>";

 

...won't do anything. If you want the fast echo syntax use

 

var startGrid="<?=$startGrid?>"

 

Or the more obvious

 

var startGrid="<?php
echo $startGrid;
?>"

 

Also avoid mysql_fetch_array unless you need both associative and numeric indices. In this case, use mysql_fetch_row.

 

Be sure to run mysql_real_escape_string on your $_REQUEST data before using it in your query.

Link to comment
https://forums.phpfreaks.com/topic/196243-getting-a-string/#findComment-1030596
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.