Jump to content

zhshero

Members
  • Posts

    58
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zhshero's Achievements

Member

Member (2/5)

0

Reputation

  1. I figure it out and btw your only working b/c you have a _ in the table name i have the - in there but this world below for me $sql = 'SELECT * FROM `lb-players`';
  2. Unable to execute query (SELECT * FROM lb-players) in the database : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-players' at line 1 I don't know why i am getting this error. All i can think of that is taking away lb from "lb-players" when you add a " - "? [m]<?php $conn = mysql_connect("23.23.23.23", "unknown", "itsAsecertxD");//ignore this xD if (!$conn) { echo "Unable to connect to the database : " . mysql_error(); exit; } if (!mysql_select_db("minecraft-rc")) { echo "Unable to select database mydbname : " . mysql_error(); exit; } $sql = 'SELECT * FROM lb-players'; $result = mysql_query($sql); if (!$result) { echo "Unable to execute query ($sql) in the database : " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to display."; exit; } while ($row = mysql_fetch_assoc($result)) { echo $row["playername"]; } mysql_free_result($result); ?>[/m] tell me if i posted this in the wrong place its been forever since i last been on this site :$
  3. line one is just a line with nothing on it i'm using notepad++ to edit files and thats how it shows 1. 2.<?php 3. include "sessionStore.php";
  4. Warning: Cannot modify header information - headers already sent by (output started at /home/zhshero/public_html/home.php:2) in /home/zhshero/public_html/functions.php on line 57 line 57 at functions.php header ( "Location: " . REDIRECT_TO_LOGIN ); i have a lot of thoses header redirects in there would it still work if i'm getting this error or no b/c of right now i'm really not sure of a way around this unless i contact my host :/
  5. i don't think i have controll over the error_reporting on the webhost :/
  6. yeah but i still don't know what that is tho the OOP magic
  7. and that solved the problem new problem Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\login.php:51) in C:\xampp\htdocs\functions.php on line 160 Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\login.php:51) in C:\xampp\htdocs\login.php on line 64 i shouldn't even be getting errors with my site all i did was moved webhosts :S
  8. everytime i go to login or register on my site i get this in the URL:http://localhost/%3C?$_SERVER['PHP_SELF']?%3E <form class="form" action="<?$_SERVER['PHP_SELF']?>" method="post">
  9. Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\ipod\lib\connection.php on line 131 :S 129. function RecordCount ( $query ) 130. { 131. return mysql_num_rows( mysql_query( $query ) ); 132. }
  10. i do have a class for it but all it dose is echo about almost everything dbh = @mysql_connect($dbhost,$dbuser,$dbpassword); if ( ! $this->dbh ) { $this->print_error(" Error establishing a database connection! Are you sure you have the correct user/password? Are you sure that you have typed the correct hostname? Are you sure that the database server is running? "); } $this->select($dbname); } // ================================================================== // Select a DB (if another one needs to be selected) function select($db) { if ( !@mysql_select_db($db,$this->dbh)) { $this->print_error(" Error selecting database $db! Are you sure it exists? Are you sure there is a valid database connection? "); } } // ================================================================== // Print SQL/DB error. function print_error($str = "") { if ( !$str ) $str = mysql_error(); // If there is an error then take note of it print " "; print "SQL/DB Error -- "; print "[$str]"; print " "; } // ================================================================== // Basic Query - see docs for more detail function query($query, $output = OBJECT) { // Log how the function was called $this->func_call = "\$ connection.php <? define("EZSQL_VERSION","5.1.41"); define("OBJECT","OBJECT",true); define("ARRAY_A","ARRAY_A",true); define("ARRAY_N","ARRAY_N",true); class db { function db($dbuser, $dbpassword, $dbname, $dbhost) { $this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword); if ( ! $this->dbh ) { $this->print_error("<ol><b>Error establishing a database connection!</b><li>Are you sure you have the correct user/password?<li>Are you sure that you have typed the correct hostname?<li>Are you sure that the database server is running?</ol>"); } $this->select($dbname); } function select($db) { if ( !@mysql_select_db($db,$this->dbh)) { $this->print_error("<ol><b>Error selecting database <u>$db</u>!</b><li>Are you sure it exists?<li>Are you sure there is a valid database connection?</ol>"); } } // ================================================================== // Print SQL/DB error. function print_error($str = "") { if ( !$str ) $str = mysql_error(); // If there is an error then take note of it print "<blockquote><font face=arial size=2 color=ff0000>"; print "<b>SQL/DB Error --</b> "; print "[<font color=000077>$str</font>]"; print "</font></blockquote>"; } function query($query, $output = OBJECT) { $this->func_call = "\$db->query(\"$query\", $output)"; $this->last_result = null; $this->col_info = null; $this->last_query = $query; $this->result = mysql_query($query,$this->dbh); if ( mysql_error() ) { $this->print_error(); return FALSE; } else { if ( $this->result ) { $i=0; while ($i < @mysql_num_fields($this->result)) { $this->col_info[$i] = @mysql_fetch_field($this->result); $i++; } $i=0; while ( $row = @mysql_fetch_object($this->result) ) { $this->last_result[$i] = $row; $i++; } @mysql_free_result($this->result); } return TRUE; } } function RecordCount ( $query ) { return mysql_num_rows ( mysql_query ( $query ) ); } function Mresult ( $query, $a, $b ) { return mysql_result ( mysql_query ( $query ), $a, $b ); } function qstr ( $string, $magic_quotes = false ) { if (!$magic_quotes) { if (strnatcmp(PHP_VERSION, '5.3.1') >= 0) { return "'" . mysql_real_escape_string($string) . "'"; } $string = str_replace("'", "\\'" , str_replace('\\', '\\\\', str_replace("\0", "\\\0", $string))); return "'" . $string . "'"; } return "'" . str_replace('\\"', '"', $string) . "'"; } function get_var($query=null,$x=0,$y=0) { $this->func_call = "\$db->get_var(\"$query\",$x,$y)"; if ( $query ) { $this->query($query); } if ( $this->last_result[$y] ) { $values = array_values(get_object_vars($this->last_result[$y])); } return $values[$x]?$values[$x]:null; } function getRow($query=null,$y=0,$output=OBJECT) { $this->func_call = "\$db->getRow(\"$query\",$y,$output)"; if ( $query ) { $this->query($query); } if ( $output == OBJECT ) { return $this->last_result[$y]?$this->last_result[$y]:null; } elseif ( $output == ARRAY_A ) { return $this->last_result[$y]?get_object_vars($this->last_result[$y]):null; } elseif ( $output == ARRAY_N ) { return $this->last_result[$y]?array_values(get_object_vars($this->last_result[$y])):null; } else { $this->print_error(" \$db->getRow(string query,int offset,output type) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N "); } } function get_col($query=null,$x=0) { if ( $query ) { $this->query($query); } for ( $i=0; $i < count($this->last_result); $i++ ) { $new_array[$i] = $this->get_var(null,$x,$i); } return $new_array; } function get_results($query=null, $output = OBJECT) { $this->func_call = "\$db->get_results(\"$query\", $output)"; if ( $query ) { $this->query($query); } if ( $output == OBJECT ) { return $this->last_result; } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { if ( $this->last_result ) { $i=0; foreach( $this->last_result as $row ) { $new_array[$i] = get_object_vars($row); if ( $output == ARRAY_N ) { $new_array[$i] = array_values($new_array[$i]); } $i++; } return $new_array; } else { return null; } } } function get_col_info($info_type="name",$col_offset=-1) { if ( $this->col_info ) { if ( $col_offset == -1 ) { $i=0; foreach($this->col_info as $col ) { $new_array[$i] = $col->{$info_type}; $i++; } return $new_array; } else { return $this->col_info[$col_offset]->{$info_type}; } } } function vardump($mixed) { echo "<blockquote><font color=000090>"; echo "<pre><font face=arial>"; if ( ! $this->vardump_called ) { echo "<font color=800080><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Variable Dump..</b></font>\n\n"; } print_r($mixed); echo "\n\n<b>Last Query:</b> ".($this->last_query?$this->last_query:"NULL")."\n"; echo "<b>Last Function Call:</b> " . ($this->func_call?$this->func_call:"None")."\n"; echo "<b>Last Rows Returned:</b> ".count($this->last_result)."\n"; echo "</font></pre></font></blockquote>"; echo "\n<hr size=1 noshade color=dddddd>"; $this->vardump_called = true; } function dumpvars($mixed) { $this->vardump($mixed); } function debug() { echo "<blockquote>"; if ( ! $this->debug_called ) { echo "<font color=800080 face=arial size=2><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Debug..</b></font><p>\n"; } echo "<font face=arial size=2 color=000099><b>Query --</b> "; echo "[<font color=000000><b>$this->last_query</b></font>]</font><p>"; echo "<font face=arial size=2 color=000099><b>Query Result..</b></font>"; echo "<blockquote>"; if ( $this->col_info ) { echo "<table cellpadding=5 cellspacing=1 bgcolor=555555>"; echo "<tr bgcolor=eeeeee><td nowrap valign=bottom><font color=555599 face=arial size=2><b>(row)</b></font></td>"; for ( $i=0; $i < count($this->col_info); $i++ ) { echo "<td nowrap align=left valign=top><font size=1 color=555599 face=arial>{$this->col_info[$i]->type} {$this->col_info[$i]->max_length}<br><font size=2><b>{$this->col_info[$i]->name}</b></font></td>"; } echo "</tr>"; if ( $this->last_result ) { $i=0; foreach ( $this->get_results(null,ARRAY_N) as $one_row ) { $i++; echo "<tr bgcolor=ffffff><td bgcolor=eeeeee nowrap align=middle><font size=2 color=555599 face=arial>$i</font></td>"; foreach ( $one_row as $item ) { echo "<td nowrap><font face=arial size=2>$item</font></td>"; } echo "</tr>"; } } else { echo "<tr bgcolor=ffffff><td colspan=".(count($this->col_info)+1)."><font face=arial size=2>No Results</font></td></tr>"; } echo "</table>"; } else { echo "<font face=arial size=2>No Results</font>"; } echo "</blockquote></blockquote><hr noshade color=dddddd size=1>"; $this->debug_called = false; } } ?>
  11. Fatal error: Call to a member function qstr() on a non-object in C:\xampp\htdocs\ipod\functions.php on line 14 <?php require_once('config.php'); function checkwork() { header("location: underwork.php"); echo 'Sorry we are under going work '; } function get_username ( $id ) { global $db; $query = "SELECT `login` FROM `" . DBPREFIX . "members` WHERE `member_id` = " . $db->qstr ( $id ); if ( $db->RecordCount ( $query ) == 1 ) { $row = $db->getRow ( $query ); return $row->login; } else { return FALSE; } } ?> this being line 14 $query = "SELECT `login` FROM `" . DBPREFIX . "members` WHERE `member_id` = " . $db->qstr ( $id );
  12. that salved the query failed part, i guess instead of using INSERT i should use UPDATE? but it isn't doing anything to my datebase
  13. i got this :S INSERT INTO members(firstname, lastname, login,) VALUES('zachary','harrison','zhshero')Query failed
  14. Can someone help me with my problem i'm trying to make and thing to update my database so i can update first name last name and login but i get a "query failed" update-exec.php <?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $fname = clean($_POST['fname']); $lname = clean($_POST['lname']); $login = clean($_POST['login']); //Input Validations if($fname == '') { $errmsg_arr[] = 'First name missing'; $errflag = true; } if($lname == '') { $errmsg_arr[] = 'Last name missing'; $errflag = true; } if($login == '') { $errmsg_arr[] = 'login missing'; $errflag = true; } //Create INSERT query $qry = "INSERT INTO members(firstname, lastname, login,) VALUES('$fname','$lname','$login')"; $result = @mysql_query($qry); //Check whether the query was successful or not if($result) { header("location: member-index.php"); exit(); }else { die("Query failed"); } ?> <form id="loginForm" name="loginForm" method="post" action="update-exec.php"> First Name<input name="fname" type="text" value="<?php echo $_SESSION['SESS_FIRST_NAME'];?>" class="textfield" id="fname" /> Last Name<input name="lname" type="text" value="<?php echo $_SESSION['SESS_LAST_NAME'];?>" class="textfield" id="lname" /> Login<input name="login" type="text" value="<?php echo $_SESSION['SESS_USERNAME'];?>" class="textfield" id="login" /> <input type="submit" name="Submit" value="Update" /> </form>
×
×
  • 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.