Jump to content
php.lv forumi

Par count


Snaip3Rs

Recommended Posts

Šādi? Negribās megināt jo ja nebūs pareizi atkal servers nobruks! :(

 

<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
$Q = mysql_query("SELECT * FROM bot") or die(mysql_error());  
if($_POST['jautajums']) // vai formas name
{
$Q = mysql_real_escape_string($_POST['jautajums']); // drosiba pirmajaa vietaa
$atbilde = mysql_fetch_assoc("SELECT count(atbilde) AS c, atbilde FROM bot WHERE jautajums = '".$Q."' GROUP BY atbilde"));
if($atbilde['c'] < 1)
{
echo "Nesapratu jautājumu";
}
else
{
echo $atbilde['atbilde'];
}
}
?>

Ieliku mysql query tikai nezinu vai pareizi!

Edited by Snaip3Rs
Link to comment
Share on other sites

[sun Apr 11 08:47:20 2010] [warn] pid file D:/web/Apache2.2/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?

PHP Warning: Directive 'register_globals' is no longer supported in PHP 6 and greater in Unknown on line 0

PHP Warning: Directive 'register_long_arrays' is no longer supported in PHP 6 and greater in Unknown on line 0

PHP Warning: Directive 'magic_quotes_gpc' is no longer supported in PHP 6 and greater in Unknown on line 0

[sun Apr 11 08:47:37 2010] [notice] Apache/2.2.8 (Win32) PHP/6.0.0-dev configured -- resuming normal operations

[sun Apr 11 08:47:37 2010] [notice] Server built: Jan 18 2008 00:37:19

[sun Apr 11 08:47:37 2010] [notice] Parent: Created child process 1940

PHP Warning: Directive 'register_globals' is no longer supported in PHP 6 and greater in Unknown on line 0

PHP Warning: Directive 'register_long_arrays' is no longer supported in PHP 6 and greater in Unknown on line 0

PHP Warning: Directive 'magic_quotes_gpc' is no longer supported in PHP 6 and greater in Unknown on line 0

[sun Apr 11 08:47:51 2010] [notice] Child 1940: Child process is running

[sun Apr 11 08:47:51 2010] [notice] Child 1940: Acquired the start mutex.

[sun Apr 11 08:47:51 2010] [notice] Child 1940: Starting 64 worker threads.

[sun Apr 11 08:47:51 2010] [notice] Child 1940: Starting thread to listen on port 80.

[sun Apr 11 09:55:07 2010] [error] [client 127.0.0.1] File does not exist: D:/web/www/favicon.ico

[sun Apr 11 09:55:11 2010] [error] [client 127.0.0.1] File does not exist: D:/web/www/favicon.ico

[sun Apr 11 11:24:36 2010] [error] [client 127.0.0.1] File does not exist: D:/web/www/favicon.ico

[sun Apr 11 11:24:39 2010] [error] [client 127.0.0.1] File does not exist: D:/web/www/favicon.ico

[sun Apr 11 11:26:58 2010] [notice] Parent: child process exited with status 3221225477 -- Restarting.

PHP Warning: Directive 'register_globals' is no longer supported in PHP 6 and greater in Unknown on line 0

PHP Warning: Directive 'register_long_arrays' is no longer supported in PHP 6 and greater in Unknown on line 0

PHP Warning: Directive 'magic_quotes_gpc' is no longer supported in PHP 6 and greater in Unknown on line 0

[sun Apr 11 11:27:14 2010] [notice] Apache/2.2.8 (Win32) PHP/6.0.0-dev configured -- resuming normal operations

[sun Apr 11 11:27:14 2010] [notice] Server built: Jan 18 2008 00:37:19

[sun Apr 11 11:27:14 2010] [notice] Parent: Created child process 3108

PHP Warning: Directive 'register_globals' is no longer supported in PHP 6 and greater in Unknown on line 0

PHP Warning: Directive 'register_long_arrays' is no longer supported in PHP 6 and greater in Unknown on line 0

PHP Warning: Directive 'magic_quotes_gpc' is no longer supported in PHP 6 and greater in Unknown on line 0

[sun Apr 11 11:27:15 2010] [notice] Child 3108: Child process is running

[sun Apr 11 11:27:15 2010] [notice] Child 3108: Acquired the start mutex.

[sun Apr 11 11:27:15 2010] [notice] Child 3108: Starting 64 worker threads.

[sun Apr 11 11:27:15 2010] [notice] Child 3108: Starting thread to listen on port 80.

Link to comment
Share on other sites

It kā nekas traks, bet varētu lēnām sākt ar šo te labošanu:

 

PHP Warning: Directive 'register_globals' is no longer supported in PHP 6 and greater in Unknown on line 0

PHP Warning: Directive 'register_long_arrays' is no longer supported in PHP 6 and greater in Unknown on line 0

PHP Warning: Directive 'magic_quotes_gpc' is no longer supported in PHP 6 and greater in Unknown on line 0

Link to comment
Share on other sites

PhP 6 vēl tikai izstrādes stadijā tāpēc labāk uzliku atpakaļ PhP 5

Un tagad gan uzmet error nevis nograujās serveris!

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\web\www\bot\bot.php on line 11

Link to comment
Share on other sites

PhP 6 vēl tikai izstrādes stadijā tāpēc labāk uzliku atpakaļ PhP 5

Un tagad gan uzmet error nevis nograujās serveris!

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\web\www\bot\bot.php on line 11

register_globas ir visai stulba lieta, tā kā to vajadzētu norubīt tāpat...

Kļūda kvērijā.

Link to comment
Share on other sites

Ne uz 11 man nau echo jo formu ar vajag lai jautājumu varētu uzdot!

 

Kods

<form method="post"> 
Jautajums: <input name="jautajums" type="text" /> <input type="submit" value="Jautat" />

<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
$Q = mysql_query("SELECT * FROM bot") or die(mysql_error());  
if($_POST['jautajums']) // vai formas name
{
$Q = mysql_real_escape_string($_POST['jautajums']); // drosiba pirmajaa vietaa
$atbilde = mysql_fetch_assoc("SELECT count(atbilde) AS c, atbilde FROM bot WHERE jautajums = '".$Q."' GROUP BY atbilde");
if($atbilde['c'] < 1)
{
echo "Nesapratu jautājumu";
}
else
{
echo $atbilde['atbilde'];
}
}
?>

 

11.Rinda

$atbilde = mysql_fetch_assoc("SELECT count(atbilde) AS c, atbilde FROM bot WHERE jautajums = '".$Q."' GROUP BY atbilde");

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...