Jump to content

Jragon

Members
  • Posts

    148
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jragon

  1. Damn i hate not being able to spell!
  2. Where you went wong: $sql="INSERT INTO information(name, email) VALUES ('.$name.','.$email.')"; Fixed: $sql="INSERT INTO information(name, email) VALUES ($name, $email)"; If you have the '' around it it will tern the vars in to normal strings. Thanks Jragon Edit: You should also use this: mysql_query($sql, $con) or die(mysql_error()) instead of that if statment cos its faster
  3. Jragon

    ++1 in MySQL

    Hey guys, I want to add 1 every time I do use this script to visits My code: <?php //Start Configeration //database host address $host = 'localhost'; //username to the database $user = 'root'; //database password $pass = ''; //database name $dbname - 'iplog'; //table to be used $tbname = 'logged_ips'; //End Configeration //finds out ip $ip = $_SERVER['REMOTE_ADDR']; //conects to the mysql server $connection = mysqli_connect($host, $user, $pass); mysql_select_db($dbname, $connection); //looks for duplacute ips if(!$dup = mysqli_query($connection, 'SELECT * FROM `logged_ips`')) { echo "Query error: ".$connection->error; die(); //stops script execution, for debugging purposes only - put proper error handling here } mysqli_free_result($dup); //checks to see if there is a duplecate name while($row = mysqli_fetch_assoc($dup)) { $ip_address = $row['Address_IP']; $visits = $row['Address_Visits'] +1; } if($ip_address != $_SERVER['REMOTE_ADDR']){ //inserts the ip in to the database $query = 'INSERT INTO `' . $dbname . '` (`Address_ID`, `Address_IP`, `Address_visits`); VALUES (\'0\', \'' . $ip . '\', \'1\');'; mysqli_query($connection, $query); }else{ //adds a visit to the database $query = "UPDATE `logged_ips` SET `Address_visits` = '++1' WHERE `ip_address` = $ip LIMIT 0,1"; mysqli_query($connection, $query); } //echos the ip echo $ip; ?> It is not working tho Any ideas would be liked =] Thanks
  4. Hey, I got a little error when trying to use this code: <?php $link = mysql_connect('localhost', 'root', '') or die(mysql_error); $query = 'CREATE DATABASE IF NOT EXISTS frtdb'; mysql_query($query, $link) or die(mysql_error($link)); mysql_select_db('frtdb', $link); $query = 'CREATE TABLE track_data ( track_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, track_name VARCHAR(32) NOT NULL, track_desc VARCHAR(250) NOT NULL, track_maker VARCHAR(32) NOT NULL, track_data LONGTEXT NOT NULL, PRIMERY KEY (track_id) ) ENGINE=MyISAM'; mysql_query($query, $link) or die(mysql_error($link)); $query = 'CREATE TABLE user_info( user_id INT UNSIGNED NOT NULL, AUTO_INCREMENT, username VARCHAR(32) NOT NULL, password VARCHAR(32) NOT NULL, salt VARCHAR(32) NOT NULL, tracks_posted INT UNSIGNED NOT NULL, date_joined DATE NOT NULL, PRIMERY KEY (user_id)) ENGINE=MyISAM'; mysql_query($query, $link) or die(mysql_error($link)); echo 'Database and Tables made!!' ?> Error: 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 'KEY(track_id)) ENGINE=MyISAM' at line 7 Thanks If you can see anymore errors please tell me.
  5. Hello, I'm getting a error when trying to use this code: <?php $link = mysql_connect('localhost', 'root', '') or die(mysql_error); $query = 'CREATE DATABASE IF NOT EXISTS frtdb'; mysql_query($query, $link) or die(mysql_error($link)); mysql_select_db('frtdb', $link); $query = 'CREATE TABLE track_data ( track_id INTEGER UNSIGNED NOT NULL, AUTO_INCREMENT, track_name VARCHAR(32) NOT NULL, track_desc VARCHAR(250) NOT NULL, track_maker VARCHAR(32) NOT NULL, track_data LONGTEXT NOT NULL)'; mysql_query($query, $link) or die(mysql_error($link)); $query = 'CREATE TABLE user_info( user_id INT UNSIGNED NOT NULL, AUTO_INCREMENT, username VARCHAR(32) NOT NULL, password VARCHAR(32) NOT NULL, salt VARCHAR(32) NOT NULL, tracks_posted INT UNSIGNED NOT NULL, date_joined DATE NOT NULL)'; mysql_query($query, $link) or die(mysql_error($link)); echo 'Database and Tables made!!' ?> Error: 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 ' track_name VARCHAR(32) NOT NULL, track_desc ' at line 2 I dont see anything wrong with it please help me find out =] Thanks Jragon
  6. Where should i put that codE?
  7. My error: Parse error: syntax error, unexpected T_START_HEREDOC in C:\xampp\htdocs\movie\table2.php on line 22 My code: <?php //connect to mysql include("connect.php"); //make sure your using the right database mysql_select_db('moviesite') or die(mysql_error); //retrive information $query = 'SELECT movie_name, movie_year, movie_director, movie_leadactor, movie_type FROM movie ORDER BY movie_name ASC, movie_year DESC'; $result = mysql_query($query) or die(mysql_error); //determine number of rows in returned result $num_movies = mysql_num_rows($result); $table <<<ENDHTML <div align="center"> <h2>Movie Review Database</h2> <table border="1" cellpadding="2" cellspacing="2" style="width: 70%; margin-left: auto; margin-right: auto;"> <tr> <th>Movie Title</th> <th>Year of Release</th> <th>Movie Director</th> <th>Movie Lead Actor</th> <th>Movie Type</th> </tr> <?php //loop through the results while ($row = mysql_fetch_assoc($result)){ extract($row); $table .= <<<ENDHTML <tr> <td>$movie_name</td> <td>$movie_year</td> <td>$movie_director</td> <td>$movie_leadactor</td> <td>$movie_type</td> </tr> ENDHTML; } $table .= <<<ENDHTML </table> <p>$num_movies Movies</p> </div> ENDHTML; ?> Please tell me what went wrong
  8. Its now sort of working this is what sorce code i get now: <table><tr><td><b>Movie Title</b></td><td><b>Lead Actor</b></td></tr><tr><td>Grand Canyon</td><td>Kevin Kline</td></tr><tr><td>Bruce Almighty</td><td>Jim Carrey</td></tr><tr><td>Office Space</td><td>Ron Livingston</td></tr></table> but it is not a table its just a list
  9. i have fiddeld with it a bit more and i now get: Not unique table/alias: 'people' my codeL <?php $link = include("connect.php"); include("connect.php"); mysql_select_db('moviesite') or die(mysql_error); $query = " SELECT movie.movie_name AS movie_title, people.people_fullname AS people_fullname FROM movie AS people JOIN movie AS people ON movie.move_leadactor = people.people_id ORDER BY titles.movie_type"; $results = mysql_query($query) or die(mysql_error()); echo "<table>"; echo "<tr><td><b>Movie Title</b></td><td><b>Lead Actor</b></td></tr>"; while($row = mysql_fetch_array($results)) { echo "<tr>"; echo "<td>".$row['movie_title']."</td>"; echo "<td>".$row['lead_actor']."</td>"; echo "</tr>"; } echo "</table>"; ?>
  10. Whats the out put source?
  11. When i try and use this code i get nothing but what i want is to have the lead actor and movie name in a table code: <?php $link = include("connect.php"); include("connect.php"); mysql_select_db('moviesite') or die(mysql_error); //select the movie titles and there ganre after 1990 $query = 'SELECT movie.movie_name, people.people_fullname FROM movie LEFT JOIN people ON people_fullname = movie_leadactor WHERE movie.movie_leadactor = people.people_id ORDER BY movie_type'; $result = mysql_query($query) or die(mysql_error); //Show results echo '<table border="1"'; while($row = mysql_fetch_assoc($result)){ echo '<tr>'; echo '<tr>'; foreach ($row as $value){ echo '<td>' . $value . '</td>'; } echo '</tr>'; } echo '</table>'; ?> mysql export: -- phpMyAdmin SQL Dump -- version 3.2.4 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jul 06, 2010 at 07:36 PM -- Server version: 5.1.41 -- PHP Version: 5.3.1 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `moviesite` -- -- -------------------------------------------------------- -- -- Table structure for table `movie` -- CREATE TABLE IF NOT EXISTS `movie` ( `movie_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `movie_name` varchar(255) NOT NULL, `movie_type` tinyint(4) NOT NULL DEFAULT '0', `movie_year` smallint(5) unsigned NOT NULL DEFAULT '0', `movie_leadactor` int(10) unsigned NOT NULL DEFAULT '0', `movie_director` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`movie_id`), KEY `movie_type` (`movie_type`,`movie_year`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; -- -- Dumping data for table `movie` -- INSERT INTO `movie` (`movie_id`, `movie_name`, `movie_type`, `movie_year`, `movie_leadactor`, `movie_director`) VALUES (1, 'Bruce Almighty', 5, 2003, 1, 2), (2, 'Office Space', 5, 1999, 5, 6), (3, 'Grand Canyon', 2, 1991, 4, 3); -- -------------------------------------------------------- -- -- Table structure for table `movietype` -- CREATE TABLE IF NOT EXISTS `movietype` ( `movietype_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, `movietype_label` varchar(100) NOT NULL, PRIMARY KEY (`movietype_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ; -- -- Dumping data for table `movietype` -- INSERT INTO `movietype` (`movietype_id`, `movietype_label`) VALUES (1, 'Sci Fi'), (2, 'Drama'), (3, 'Adventure'), (4, 'War'), (5, 'Comedy'), (6, 'Horror'), (7, 'Action'), (8, 'Kids'); -- -------------------------------------------------------- -- -- Table structure for table `people` -- CREATE TABLE IF NOT EXISTS `people` ( `people_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `people_fullname` varchar(255) NOT NULL, `people_isactor` tinyint(1) unsigned NOT NULL DEFAULT '0', `people_isdirector` tinyint(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`people_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; -- -- Dumping data for table `people` -- INSERT INTO `people` (`people_id`, `people_fullname`, `people_isactor`, `people_isdirector`) VALUES (1, 'Jim Carrey', 1, 0), (2, 'Tom Shadyac', 0, 1), (3, 'Lawrence Kasdan', 0, 1), (4, 'Kevin Kline', 1, 0), (5, 'Ron Livingston', 1, 0), (6, 'Mike Judge', 0, 1); Please help Thanks Jragon
  12. Hello I'm getting an error Error: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\Sliqer.php on line 29 Code: <?php //Start Configeration //database host address $host = 'localhost'; //username to the database $user = 'root'; //database password $pass = ''; //database name $dbname - 'iplog'; //table to be used $tbname = 'logged_ips'; //End Configeration //finds out ip $ip = $_SERVER['REMOTE_ADDR']; //conects to the mysql server $connection = mysqli_connect($host, $user, $pass); //looks for duplacute ips $dup = mysqli_query($connection, 'SELECT * FROM `logged_ips`'); //checks to see if there is a duplecate name while($row = mysqli_fetch_assoc($dup)) { $ip_address = $row['Address_IP']; $visits = $row['Address_Visits'] +1; } if($ip_address != $_SERVER['REMOTE_ADDR']){ //inserts the ip in to the database $query = 'INSERT INTO `' . $dbname . '` (`Address_ID`, `Address_IP`, `Address_visits`); VALUES (\'0\', \'' . $ip . '\', \'1\');'; mysqli_query($connection, $query); }else{ //adds a visit to the database $query = "UPDATE `logged_ips` SET `Address_visits` = '++1' WHERE `ip_address` = $ip LIMIT 0,1"; mysqli_query($connection, $query); } //echos the ip echo $ip; ?> Thanks Jragon
  13. Is there a way so i can automaticly get updates from the forum when someone replys to my thread without telling it to send me updates eatch time? Thanks Jragon
  14. Hello, when i am trying to see what mysql error is it dose not work Code: <?php $link = include("connect.php"); include("connect.php"); mysql_select_db('moviesite') or die(mysql_error); //select the movie titles and there ganre after 1990 $query = 'SELECT movie.movie_name, movietype.movietype_lable FROM movie, movietype WHERE movie.movie_type = movietype.movietype_id AND movie_year > 1990 ORDER BY movie_type'; $result = mysql_query($query) or die(mysql_error); //Show results echo '<table border="1"'; while($row = mysql_fetch_assoc($result)){ echo '<tr>'; echo '<tr>'; foreach ($row as $value){ echo '<td>' . $value . '</td>'; } echo '</tr>'; } echo '</table>'; ?> I Would like to see what the error is but its not working
  15. You now how to play this game! go! 1
  16. What is Sliger? Sliger is a Smart loger of ip adresses Why the name Sliger? well Silger stands for: S=Smart L=loger I=IP GER=the end bit on loger Why is it smart? well it is not smart yet but hay i got as much time as i want (i'm only 12) Features 1.0: logs ip to txt file desplays ip 2.0: logs ip to txt file desplays ip only logs the ip if there is not allready a ip in the text file Sliger 1.0: The file The source code: <?php //finds out ip $ip = $_SERVER['REMOTE_ADDR']; //path to ip logs file direcotry $path = 'directory to store logs'; //path to log file $logfile = 'log file name'; //construct path $absLogfile = $path . $logfile; //looks to see if dose not file exits if (!file_exists($absLogfile)) { //makes the file $f = fopen($absLogfile, 'w+'); }else{ //opens the file redy to wright $f = fopen($absLogfile, 'a+'); //wittes the ip to the file fwrite($f, $ip."\n"); //closes the file fclose($f); } //echo's the ip echo $ip; ?> Sliger 2.0: The Page chek it out: <?php //finds out ip $ip = $_SERVER['REMOTE_ADDR']; //path to ip logs file direcotry $path = 'PATH TO LOG FILE'; //path to log file $logfile = $path . 'LOG FILE NAME'; //looks to see if dose not file exits if (!file_exists($logfile)) { //makes the file $f = fopen($logfile, 'w+'); }else{ //opens the file redy to wright $f = fopen($logfile, 'a+'); //looks for data from log file $data = fread($f, filesize($logfile)); //looks to see if there is a ip thats the same $pos = strpos($data, $ip); //if in $pos there is no ip thats the same as the ips logged if ($pos != true) { //wittes the ip to the file fwrite($f, $ip . "\n"); //closes the file fclose($f); }else if($pos != false){ echo "This IP address is already recorded. <br />"; } } echo $ip ?> How to install 2.0: 1. make a text file with the info "Logz:" 2. upload it to your log dir 3. upload your sliger file Sliqer 1.0: Features Logs IP to a database Code: <?php //Start Configeration //database host address $host = 'jragoncouk.ipagemysql.com' //username to the database $user = 'ipadmin' //database password $pass = 'md50i' //database name $dbname - 'iplog' //table to be used $tbname = 'logged_ips' //End Configeration //finds out ip $ip = $_SERVER['REMOTE_ADDR']; //conects to the mysql server $connection = mysql_connect($host, $user, $pass); //sellects the database mysql_select_db($connection, $dbname); //inserts the ip in to the database $query = 'INSERT INTO `' . $dbname . '` (`Address_ID`, `Address_IP`, `Address_visits`); VALUES (\'0\', \'' . $ip . '\', \'1\');'; mysqli_query($connection, $string); //echos the ip echo $ip; ?> MySQL Table make code: CREATE TABLE `logged_ips` ( `Address_ID` int(11) NOT NULL auto_increment, `Address_IP` varchar(68) NOT NULL, `Address_Visits` int(11) NOT NULL, PRIMARY KEY (`Address_ID`) ) ENGINE=MyISAM AUTO_INCREMENT=38 DEFAULT CHARSET=latin1 AUTO_INCREMENT=38 ; Sliqer 2.0(beta) Features Logs IP only if IP is not allreadey logged adds a Visit if ip is allready logged Code: <?php //Start Configeration //database host address $host = '**' //username to the database $user = '**' //database password $pass = '**' //database name $dbname - 'iplog' //table to be used $tbname = 'logged_ips' //End Configeration //finds out ip $ip = $_SERVER['REMOTE_ADDR']; //conects to the mysql server $connection = mysqli_connect($host, $user, $pass); //sellects the database mysql_select_db($connection, $dbname); //looks for duplacute ips $dup = getFields($dbname, $tbname); //checks to see if there is a duplecate name if(mysql_num_rows($dup) !> 0){ //inserts the ip in to the database $query = 'INSERT INTO `' . $dbname . '` (`Address_ID`, `Address_IP`, `Address_visits`); VALUES (\'0\', \'' . $ip . '\', \'1\');'; mysql_query($connection, $string); }else{ //adds a visit to the database $string2 = "UPDATE `logged_ips` SET `Address_visits` = '++1' WHERE `ip_address` = $ip LIMIT 0,1"; mysql_query($connection, $string2) or die('Error: ' mysql_error); } //echos the ip echo $ip; ?> MySQL Table make code: CREATE TABLE `logged_ips` ( `Address_ID` int(11) NOT NULL auto_increment, `Address_IP` varchar(68) NOT NULL, `Address_Visits` int(11) NOT NULL, PRIMARY KEY (`Address_ID`) ) ENGINE=MyISAM AUTO_INCREMENT=38 DEFAULT CHARSET=latin1 AUTO_INCREMENT=38 ; I am still encontering some errors... Please correct my liqer 2.0 i dont know what is wron with it Thanks to: Mark for helping me with the errors Joel who gave me the idea Tea for keeping me up all night Me for the programming P.S. this is my first project i have tried with out a tutorial so please dont be too harsh P.P.S if you think the comments are bad please repace them with better ones
  17. Hello my fellow phpfreaks, I am having trubble with my php moviesite project. my error: Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\movie\select2.php on line 27 My code: <?php include("connect.php"); mysql_select_db('moviesite'); //select the movie titles and there ganre after 1990 $query = 'SELECT movie_name, movie_type FROM movie WHERE movie_year > 1990 ORDER BY movie_type'; $result = mysql_query($query) or die('Error: ' . mysql_error); //Show results echo '<table border="1"'; while($row = mysql_fetch_assoc($result)){ echo '<tr>'; echo '<tr>'; foreach ($row as $value){ echo '<td>' . $value . '</td>'; } echo '</tr>'; } echo '</table'>; ?> Thanks jragon
  18. Hello, I'm jragon Do you have to enter the verification each time you post? Thanks jragon
×
×
  • 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.