
Mianowicie tworzę sobie taką małą grę i problem jest następujący:
Podczas rejestracji nowego użytkownika wyskakuje taki błąd:
Kod
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\usr\krasnal\www\gra\stats.php on line 43
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\usr\krasnal\www\gra\stats.php on line 43
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\usr\krasnal\www\gra\stats.php on line 43
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\usr\krasnal\www\gra\stats.php on line 43
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\usr\krasnal\www\gra\stats.php on line 43
Skorzystałem też z
i pokazał taki komunikat:
Kod
Something is wrong in your syntax obok 'SELECT id FROM stats WHERE display_name = 'mag' OR short_name = ' w linii 1
Wychodzi na to, że chyba wykonanie zapytania się nie powiodło.
W czym może tkwić błąd?
Dodatkowo kod stats.php
<?php function getStat($statName,$userID) { include 'config.php'; createIfNotExists($statName,$userID); $query = sprintf("SELECT value FROM user_stats WHERE stat_id = (SELECT id FROM stats WHERE display_name = '%s' OR short_name = '%s') AND user_id = '%s'", return $value; } function setStat($statName,$userID,$value) { include 'config.php'; createIfNotExists($statName,$userID); $query = sprintf("UPDATE user_stats SET value = '%s' WHERE stat_id = (SELECT id FROM stats WHERE display_name = '%s' OR short_name = '%s') AND user_id = '%s'", } function createIfNotExists($statName,$userID) { include 'config.php'; $query = sprintf("SELECT count(value) FROM user_stats WHERE stat_id = (SELECT id FROM stats WHERE display_name = '%s' OR short_name = '%s') AND user_id = '%s'", if($count == 0) { $query = sprintf("INSERT INTO user_stats(stat_id,user_id,value) VALUES ((SELECT id FROM stats WHERE display_name = '%s' OR short_name = '%s'),'%s','%s')", '0'); } } ?>
Oraz register.php
<?php include 'smarty.php'; if($_POST) { $password = $_POST['password']; $confirm = $_POST['confirm']; if($password != $confirm) { $error = 'Passwords do not match!'; } else { require_once 'config.php'; if($count >= 1) { $error = 'that username is taken.'; } else { require_once 'stats.php'; setStat('atk',$userID,'5'); setStat('def',$userID,'5'); setStat('mag',$userID,'5'); $message = 'Congratulations, you registered successfully!'; } } } $smarty->assign('error',$error); $smarty->assign('message',$message); $smarty->display('register.tpl'); ?>