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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.