Jump to content

Recommended Posts

I need to update a table in mysql and the information is very long. I changed it to Longtext and whenever i use php to update it, the query returns true but the data never gets inserted into the database. Here is an example of the text that would be entered:

 

PokerStars Game #10117033922:  Hold'em No Limit ($0.10/$0.25) - 
2007/05/26 - 16:54:47 (ET)
Table 'Io V' 6-max Seat #3 is the button
Seat 1: Graffin13 ($2 in chips) 
Seat 3: toze2 ($16.40 in chips) 
Seat 6: cdsaz ($17.75 in chips) 
cdsaz: posts small blind $0.10
Graffin13: posts big blind $0.25
*** HOLE CARDS ***
Dealt to Graffin13 [7s Tc]
toze2: calls $0.25
cdsaz: calls $0.15
Graffin13: checks 
*** FLOP *** [Td Th 6d]
cdsaz: checks 
Graffin13: checks 
toze2: bets $0.25
cdsaz: folds 
Graffin13: calls $0.25
*** TURN *** [Td Th 6d] [8d]
Graffin13: checks 
toze2: bets $1
Graffin13: raises $0.50 to $1.50 and is all-in
toze2: calls $0.50
*** RIVER *** [Td Th 6d 8d] [5h]
*** SHOW DOWN ***
Graffin13: shows [7s Tc] (three of a kind, Tens)
toze2: shows [Ts 9d] (three of a kind, Tens - Nine kicker)
toze2 collected $4.05 from pot
*** SUMMARY ***
Total pot $4.25 | Rake $0.20 
Board [Td Th 6d 8d 5h]
Seat 1: Graffin13 (big blind) showed [7s Tc] and lost with three of a 
kind, Tens
Seat 3: toze2 (button) showed [Ts 9d] and won ($4.05) with three of a 
kind, Tens
Seat 6: cdsaz (small blind) folded on the Flop

 

one thing i noticed is that when I used phpmyadmin to update the data manually, i generated the PHPcode that it uses and it added apostrophes (') to the beginning and end of each line.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/53189-long-insert/
Share on other sites

can you specify more? I did

 

$slashes = addslashes($ph);
$myDb->query("UPDATE xxxx set pokerhand='$slashes' WHERE hand = '$hand'");

 

This still doesn't insert the data into the database.

 

P.S. When i finally do get the data out will i have to use stripslashes();?

 

Thanks again

 

Link to comment
https://forums.phpfreaks.com/topic/53189-long-insert/#findComment-262794
Share on other sites

yes to the second part about stripslashes() when you pull it back out again.

 

echo out $slashes and have a look at it

 

test 1 .................

$slashes = "Hello World";
$myDb->query("UPDATE xxxx set pokerhand='$slashes' WHERE hand = '$hand'");

 

check to see if it sticks that in the database, if not then its not the longtext problem but the query problem....

 

if that works then it is the $slashes thats the problem and will need more looking at.

Link to comment
https://forums.phpfreaks.com/topic/53189-long-insert/#findComment-262802
Share on other sites

Take a look:

 

Whenever I insert the data into the database it stays in there. When I try to extract it it works perfectly. What is my problem you ask?

When I extract the data out of the database it assigns the data to the variable $ph but it never loads when i try to go back to the page. For example: I hit submit on the first page. The next page loads perfectly as it should. However when you go to the link for example view.php?hand=38 then it is as if no data was taken out of the database.

 

class db {

        function connect($db_host, $db_user, $db_pass, $db_name) {
        mysql_connect($db_host, $db_user, $db_pass);
        mysql_select_db("$db_name") or die(mysql_error());
        }

        function query($query) {
        $query = mysql_query($query) or die(mysql_error());
        return $query;
        }

        function fetch_array($query) {
        $query = mysql_fetch_array($query);
        return $query;
        }

        function fetch_row($query) {
        $query = mysql_fetch_row($query);
        return $query;
        }

        function close() {
        mysql_close();
}
}

  $myDb=new db;

  $myDb->connect($db_host, $db_user, $db_pass, $db_name);
$query = $myDb->query("Select * from poker WHERE link='$hand'");

$row = $myDb->fetch_array($query);

$rowhand = $row['pokerhand'];


if(mysql_num_rows($query)>1)
{
$myDb->query("UPDATE poker set pokerhand='$rowhand' WHERE link='$hand'");

}
else
{
$ph = $_POST['pokerhand'];

$myDb->query("UPDATE poker set pokerhand='$ph' WHERE link='$hand'");

}

$ab = $myDb->query("SELECT pokerhand FROM poker WHERE link='$hand'");
$newrow = $myDb->fetch_array($ab);
$cd = $newrow['pokerhand'];
$de = nl2br($cd);
$ph = stripslashes($de);

 

And then it processes the information found in $ph and does all of the functions.

Link to comment
https://forums.phpfreaks.com/topic/53189-long-insert/#findComment-262853
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.