Jump to content

zhshero

Members
  • Posts

    58
  • Joined

  • Last visited

    Never

Everything posted by zhshero

  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>
  15. my webhost told me there was a infinite loop that in a matter of 30seconds used up over 12GB can someone help me find this and stop the loop for doing so? or is there a program that could help me with this kind of stuff <?php include "sessionStore.php"; $userfinal = get_username($_SESSION['user_id']); $the_time = time(); mysql_query("UPDATE users SET date='$the_time' WHERE Username='$userfinal'")or die(mysql_error()); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Zhshero Friends</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"> <h1><font color=white>ZhsHero Friends</h1> <h2>Making the world a better place </h2> </div> <div id="menu"> <ul> <li><a href="http://zhshero.freehostingcloud.com/home.php">Home</a></li> <li class="active"><a href="http://zhshero.freehostingcloud.com/mymembers.php">Members</a></li> <li><a href="http://zhshero.freehostingcloud.com/update_profile.php">Settings</a></li> <li><a href="http://zhshero.freehostingcloud.com/inbox/">Inbox <? $sql = mysql_query("SELECT count(message_id) FROM messages WHERE to_user='$userfinal' AND message_read='0'"); $total = mysql_fetch_array($sql); $num = $total[0]; echo $num; ?> </a></li> <li><a href="http://zhshero.freehostingcloud.com/logout.php">Logout</a></li> </ul> </div> <div id="content"> <div id="colOne"> <center><h2><font color=white><?php echo 'Welcome ' . get_username ( $_SESSION['user_id'] ) . ' '; ?></h2> <p><img src="<? echo get_main_P ( $_SESSION['user_id'] ) ?>" border=1 width="135" height="150"></p> </center> <h2><font color=white>News box</h2> <p><? $result = mysql_query("SELECT * FROM otherapia"); while($row = mysql_fetch_array($result)) { echo $row['id'] . " " . $row['news']; } ?></p> </div> <div id="colTwo"> <h2><font color=white> ZhsHero Friends Users - <a href="http://zhshero.freehostingcloud.com/who_online.php">View online users only</a></h2> <p> <center><table border=2 width="250" height="125"><tr> <? $Members = mysql_query("SELECT * FROM users") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <?php for($count = 4/n; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <td width="150" height="125"> <a href="view_profile.php?username=<? echo $name['Username']?>"><img src="<? echo $name['main_P']?>" width="100" height="100"/> <? echo $name['Username']?></a> <? if (isset($name['date']) && (time() - $name['date'] > 300)) { echo 'offline'; } else { echo "<font color=green>[Online]</font>"; } $name['date'] = time(); // update last activity time stamp ?> </td> <? } ?> </tr></table></center> </p> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <p>Copyright © 2010 ZhsHero LTD. Designed by <a href="http://www.freecsstemplates.org/"><strong>Free CSS Templates</strong></a></p> </div> <center><a href="http://www.adleaf.com" style="font-size:12px;">Free Advertising</a><br/><script type="text/javascript"> riv_client = 318310; riv_backgroundColor = '000000'; riv_borderColor = '000066'; riv_headlineColor = '669900'; riv_textColor = 'FFFFFF'; riv_linkColor = 'CC3300'; riv_adWidth = 728; riv_adHeight = 90; riv_adType = 4; </script> <script type="text/javascript" src="http://ad1.adleaf.com/js/rivad.js"></script> </body> </html>
  16. can you show me an example?
  17. i already have checked it out
  18. Hey i'm just wanting to make a loop to loop members i do have a loop but im looking for a more better loop i need to loop my members in a table as spot: 1 spot: 2 spot: 3 spot 4 and if there more it puts in below the top for spots and so on $Members = mysql_query("SELECT * FROM users") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <td width="150" height="125"> <a href="view_profile.php?username=<? echo $name['Username']?>"><img src="<? echo $name['main_P']?>" width="100" height="100"/> <? echo $name['Username']?></a> <? } ?>
  19. takes forever to load phpmyadmin -,- i beleive there nothign wrong with that code since it failed to insert by into the database <? include "sessionStore.php"; $Username = $_GET['username']; $user = mysql_query("SELECT * FROM users WHERE Username = '$Username'"); $user=mysql_fetch_assoc($user); $userfinal = get_username($_SESSION['user_id']); $by = $userfinal; //you $query = mysql_query("INSERT INTO `friend_requests` ( `username` , `by` ) VALUES ( '$Username' , '$by' )"); //inserts the request echo ( "$username has been sent a request you must now wait for it to be accepted" ); //echos completion ?> to me i don't really see a probably with this, tho it might not be secure tho
  20. well all i know is when i last tested the code, it worked fine, but now i was just testing again to make sure it work, well it was doing that i haven't edited anything :S im checking my database to see if it missed anything while inserting data into mysql
  21. sorry this supposed to grab friend requests from the database it for accepting new friends or deleting the friend request but when i click accept i notice that url to accept that user isn't working right <a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a><br/> <a href='newfriends.php?friends=delete&user=$reqs[by]'>Delete</a>" ); //displays requests and shows accept delete links its jsut showing up like this newfriends.php?friends=delete&user= when there should be a username beside $user=<username>
  22. Can someone help me get this working <?php include "sessionStore.php"; $userfinal = get_username($_SESSION['user_id']); if ($userfinal[username]) { //checks user is logged in switch ($_GET[friends]) { //allows multiple pages default: $get = mysql_query( "SELECT * FROM `friend_requests` WHERE `username` = '$userfinal' "); //gets requests while ($reqs = mysql_fetch_array($get)) { echo ( "Friend Requests $reqs[by] wants to be friends with you. <a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a><br/> <a href='newfriends.php?friends=delete&user=$reqs[by]'>Delete</a>" ); //displays requests and shows accept delete links } break; case 'accept': //accept page if ($_GET[user]) { //get username $add = mysql_query( "INSERT INTO `friends` (`friendname` , `username`, `added`) VALUES ('$_GET[user]' , '$userfinal' , '1') "); // add to your friends list $delete = mysql_query( "DELETE FROM `friend_requests` WHERE `by` = '$_GET[user]' "); // deletes friend request echo ( "$_GET[user] has been added as a friend and the request has been deleted" ); // echos the completion } break; //ends accept page case 'delete': // delete page if ($_GET[user]) { //gets username $delete = mysql_query( "DELETE FROM `friend_requests` WHERE `by` = '$_GET[user]' "); // deletes friend request echo ( "$_GET[user]'s request has been deleted" ); // echos completion } break; //ends delete page } // ends switch } else { echo ( "You need to be logged in" ); // not logged in } ?>
  23. ok nvm i got what i needed <? $Members = mysql_query("SELECT * FROM friends WHERE username='$Username'") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <? echo $name['friendname']?></a> <? } ?>
  24. Hey i'm just woundering how i would echo numbers from a database like 1000000 lets say 1 million how would i go about on echoing it like this 1,000,000 ZhsHero
×
×
  • 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.