php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18070 INSERT failure
Submitted: 2002-06-30 04:46 UTC Modified: 2002-07-05 13:02 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:3 (100.0%)
From: Akujin11 at yahoo dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.2.0 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: Akujin11 at yahoo dot com
New email:
PHP Version: OS:

 

 [2002-06-30 04:46 UTC] Akujin11 at yahoo dot com
I'll start with the code that is the source of the problem:

function submit_values($char_name, $str, $spe, $skill, $def, $pow) {
   $submittal = "INSERT INTO stats (name, strength, speed, skill, defense, power)
                 VALUES ('$char_name', $str, $spe, $skill, $def, $pow);";

   $submittal_q = mysql_query($submittal) or
     die(mysql_error());
 
   echo "Added $char_name, $str, $spe, $skill, $def, $pow";
 }

now that the code is stated, i'll give the problem, and it is a simple one: this code does nothing. it is the same exact code i was using successfully before upgrading to 4.2.0, however now it does absolutly nothing. the code processes, acts as if nothing is wrong, however when executed absolutly no information is being added to my database.

i request that you NOT simply say "consult the users manual" like you have to so many other people, because it solves nothing. i would like a REAL solution to this problem.

-The Akujin.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-30 04:54 UTC] sander@php.net
You're _very_ likely doing something wrong. Does mysql_error() say something? Can you use insert rows with for example phpMyAdmin?
 [2002-06-30 05:03 UTC] Akujin11 at yahoo dot com
i have tried several methods of inserting rows and everything has failed. the only way i can insert data is to open MySQL and insert it manually thought the DOS prompt. i have noticed that a LOT of people are having the same problem. 

my setup is the same as it was before i upgraded, and the code is exactly the same (i'm using the same, unmodified, file) and yet after the upgrade my insert functions cease to work. a SELECT query does, however, work.
 [2002-06-30 06:47 UTC] derick@php.net
Try the latest version (4.2.1) first
 [2002-06-30 07:05 UTC] Akujin11 at yahoo dot com
i downloaded and installed 4.2.1 and it still does not work.

Here, see the file for yourself and see if you can add any input:

http://24.127.136.211/enter_char.php
 [2002-07-03 21:49 UTC] sniper@php.net
That example of yours doesn't work quite right..
Where's the source for it?
(the given url..)

 [2002-07-04 00:12 UTC] Akujin11 at yahoo dot com
thats the POINT. it doesn't work right. it can call data from my database (so i know the connection works) but it refuses to insert anything. 

the source is as follows:

<html>
<head>
<title>Character Entry Form</title>
</head>
<body>
<?php 

  mysql_connect("localhost", "root") or die("Could not establish a connection to the database.");
  mysql_select_db("MvC2") or die("Could not select the given database.");

  function submit_values($char_name, $char_game, $char_alias) {
	$insert_query = "INSERT INTO characters VALUES ('$char_name', '$char_game', '$char_alias');";
	mysql_query($insert_query) or die(mysql_error());
  }

  function results() {

?>
<table width=400 border=1>
 <tr>
  <td width=150>Name</td>
  <td width=50>Game</td>
  <td width=150>Alias</td>
 </tr>
<?
	$result_query = "SELECT * FROM characters ORDER BY name;"; 	
 	$result_value = mysql_query($result_query) or die(mysql_error());
 	$x = 0;
 	while ($row = mysql_fetch_array($result_value)) {
  		if(($x % 2) == 0) { $c = "#cccccc"; }
 		else { $c = "#FFcccc"; }
		?>
 <tr>
  <td bgcolor="<?= $c; ?>"><?= $row["name"]; ?></td>
  <td bgcolor="<?= $c; ?>"><?= $row["game"]; ?></td>
  <td bgcolor="<?= $c; ?>"><?= $row["c_alias"]; ?></td>
 </tr>
<? $x++; } ?>
</table>
   <?
 }


 function show_input() {
   ?>
<form method=post action="<?php $PHP_SELF ?>">
<table width=400 rules="none">
 <tr>
  <td>Name:</td>
  <td><input type="text" name="character">
 </tr>
 <tr>
  <td>Game:</td>
  <td><input type="text" name="game">
 </tr>
 <tr>
  <td>Alias:</td>
  <td><input type="text" name="alias">
 </tr>
 <tr>
  <td><input type="submit" name="submit" value="insert character"></td>
  <td><input type="reset" value="reset"></td>
 </tr>
</table>
</form>
   <?
 }

 if ($submit) {
 	$insert_query = "INSERT INTO characters VALUES ('Akuma', 'game', 'alias');";
	mysql_query($insert_query) or die(mysql_error());
	show_input();
	results();
 } else {
	show_input();
	results();
 }

?>

</body>
</html>

see what you can make of it, but i'm telling you the problem lies not with the code (which i personally wrote, and that worked untill my upgrade), but insted with the new release. if you look at the number of people that are having this same problem you will see that the evidence does point that way.
 [2002-07-04 09:09 UTC] sniper@php.net
Try changing that $PHP_SELF to $_SERVER['PHP_SELF']
as that didn't work..


 [2002-07-05 02:35 UTC] Akujin11 at yahoo dot com
i made the change you suggested, it still refuses to add data.

by the way, the Akuma you see there is from my database, so you can see that the connection is working.
 [2002-07-05 04:05 UTC] sniper@php.net
Please check your script, and especially those warnings/errors that come when you load it..
It's still sending the post to wrong script.

 [2002-07-05 04:12 UTC] Akujin11 at yahoo dot com
trust me, i have. over and over and over and over and over and over and over again.
 [2002-07-05 04:28 UTC] sniper@php.net
And I'm really close at making this bogus since I still see the same errors at this page:

http://24.127.136.211/enter_char.php

Please, fix that example page first..

 [2002-07-05 04:39 UTC] Akujin11 at yahoo dot com
i can't seem to get that notice to go away (which is really odd because there wasn't even a notice untill i switched to 4.2.1).

any tips?
 [2002-07-05 04:43 UTC] sniper@php.net
In PHP 4.2.0, the 'register_globals' setting default changed to
be off. See http://www.php.net/release_4_2_0.php for more info.
We are sorry about the inconvenience, but this change was a necessary
part of our efforts to make PHP scripting more secure and portable.


 [2002-07-05 13:02 UTC] Akujin11 at yahoo dot com
Found the problem. it is not with the script but with my php.ini file. 

thanks for the help, i probably never would have found that on my own.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 07:01:29 2024 UTC