Jump to content

Search the Community

Showing results for tags 'mysql_query'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 6 results

  1. Hello, I am doing a project where I need to store a large volume of data in a table. So, I can't show all the data at a time. And performing a query for all those data may be time consuming. So I want to implement a view system where I can show data step by step. Say I want to show last 50 data at a time. So, It seems that I need to traverse through the rows with two button. "Previous" and "Next" . What could be the query for this purpose or how I can do it? I am using mysql and php. I am not expecting a bunch of code. But I will appreciate your comment with necessary functions for php and query ideas or examples for mysql and viewing procedure for HTML.
  2. so i have problem with using mysql and php. i wanted to create a guestbook using a table which has: id,date, name,mail,txt and ip. and then i wrote this: <?PHP $connect = mysql_connect("localhost","",""); mysql_select_db("site1",$connect); mysql_query("SET NAMES utf8") or die(mysql_error()); $read = mysql_query('SELECT * FROM guestbook ORDER BY date ') or die(mysql_error()) ; $mass = mysql_fetch_array($read); ?> </head> <body> <form action='bb.php?click' method='post'> name:<input type="text" name="name" /><br /> mail:<input type="text" name="mail" /><br /> comment:<textarea name="txt" rows="7"></textarea><br /> adress <input type='submit' value='ENTER' /> </form> <?PHP if(isset($_GET['click'])) { $date = date("Y-m-d"); $mass['ip'] =$_SERVER['REMOTE_ADDR']; $_POST['mail'] = htmlspecialchars($_POST['mail']); $_POST['mail'] = stripslashes($_POST['mail']); $_POST['mail'] = trim($_POST['mail']); $ins = mysql_query("INSERT INTO guestbook(name,mail,txt) VALUES('$_POST[name]','$_POST[mail]','$_POST[txt]')"); if(isset($ins)) {echo $mass['name']." ";echo $mass['mail']." ";echo $mass['date']."<br />"; echo $mass['text']."<br />"; echo "<hr width=100% />"; } else echo mysql_error(); } ?> and after i insert and submit something it doesnt recognize the $_POST variables because the they dont exist anymore so what should i do???
  3. Good Day I was wondering if anyone could help me mysql does not seem to be working correctly MySQL server version: -- 5.5.24 the raw MySQL statement in question [mysql_query ("UPDATE ".$db_prefix."banner SET `shown`=0");] any errors that MySQL returns to the client [No ERROR just not updating] the table structure & column indexes of the relevant tables [-- -- Database: `second` -- -- -------------------------------------------------------- -- -- Table structure for table `shc_banner` -- CREATE TABLE IF NOT EXISTS `shc_banner` ( `idx` int(10) unsigned NOT NULL AUTO_INCREMENT, `banner_type` char(3) NOT NULL DEFAULT '', `cat_id` int(10) NOT NULL, `dir_id` char(3) NOT NULL, `banner_order` varchar(255) NOT NULL, `banner_file` varchar(255) NOT NULL DEFAULT '', `banner_title` varchar(255) NOT NULL DEFAULT '', `banner_url` varchar(255) NOT NULL DEFAULT '', `viewslimit` int(11) NOT NULL COMMENT 'After this amount of views has been reached, the ad will be expired. - 0 To disable', `clickslimit` int(11) NOT NULL COMMENT 'After this amount of clicks has been reached, the ad will be expired. - 0 to disable', `banner_target` varchar(255) NOT NULL, `banner_width` int(4) NOT NULL, `banner_height` int(4) NOT NULL, `banner_owner` varchar(255) NOT NULL DEFAULT '', `banner_dir` varchar(1000) NOT NULL, `banner_cat` varchar(1000) NOT NULL, `banner_hits` varchar(255) NOT NULL, `banner_clicks` varchar(255) NOT NULL, `show` int(1) DEFAULT NULL, PRIMARY KEY (`idx`), KEY `banner_type` (`banner_type`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Random Banner' AUTO_INCREMENT=170 ; -- -- Dumping data for table `shc_banner` --] the EXPLAIN output for your query: the query should update the database table but it does not in attached file line 64-67 a clear and concise description of what you want this statement to achieve: That the statment should update my table but it does not a description of what it's currently doing that's not to your liking: its not updating the table/ not even sowing up in debug mode localhost not live if anybody can help I'm new to this and could not find any solution at all Regards Rhino window.php
  4. Bear with me, I'm new to PHP and MySQL. Ok, so strange thing. Last night, I'm coding it up, everything's working great. Go to bed, wake up, now my form isn't working. Literally 9 hours before, it was. Nothing changed, suddenly isn't working. I have 2 files, form.php and insert.php. form.php: <html> <head> <title>YAY!</title> </head> <body> <h2>Register Form</h2> <form method="get" action="insert.php"> <table border="0" width="60%"> <tr> <td width="10%">Referred By: </td><td><input type="text" name="referredby" /></td> </tr> <tr> <td width="10%">Email: </td><td><input type="text" name="email" /></td> </tr> <tr> <td width="10%">Name: </td><td><input type="text" name="name" /></td> </tr> <tr> <td width="10%">Password: </td><td><input type="text" name="password" /></td> </tr> <tr> <td width="10%">Earned: </td><td><input type="text" name="earned" /></td> </tr> <tr> <td width="10%">Image: </td><td><input type="text" name="image" /></td> </tr> </table> <p> <input type="submit" value="Register" /> <input type="reset" value="reset" /> </form> </body> </html> insert.php: <?php $referredby = $_REQUEST['referredby']; $email = $_REQUEST['email']; $name = $_REQUEST['name']; $password = $_REQUEST['password']; $earned = $_REQUEST['earned']; $image = $_REQUEST['image']; if($email && $name && $password && $password && $earned) { mysql_connect("dbserver", "username", "password") or die("Problem connecting to the database server. Please contact administrator at <link to contact form here> with the following error message: " . mysql_errno() . ": " . mysql_error() . "<br />" ); mysql_select_db("database"); mysql_query("INSERT INTO desiredtable(referredby,email,name,password,earned,image) VALUES('$referredby','$email','$name','$password','$earned','$image')"); $registered = mysql_affected_rows(); echo "$name was successfully registered! $registered row(s) added to the table."; mysql_close(); }else{ echo "You have to complete the form<br />"; echo "Email: " . $email . "<br />" . "Name: " . $name . "<br />" . "password: " . $password . "<br />" . "Earned: " . $earned . "<br />"; } echo mysql_errno() . ": " . mysql_error() . "<br />"; echo "<a href=\"form.php\">Return to the previous page</a>" ?> Now, here's the kicker. When I fill out the form and click register, I have my else { } statement echo the $_REQUEST[ ] variables (added that for troubleshooting), and it's displaying the contents correctly. I even changed my form from method="post" to method="get" to verify in the address bar. Apparently, everything before and after the initial IF statement conditions are working correctly. It's the conditions that are not, which doesn't make sense, because as I said, I was using it last night in order to add entries into my table. It's probably something really simple stupid, and I'm hoping you can help me out with it :/ FYI, this is set up under a XAMPP installation on my PC
  5. Hey guys, This is my first proper php app. so be nice I have a mysql_query that joins a two tables, it's working properly, but I want to add one extra variable with the results. $topRanked = mysql_query("SELECT * FROM news JOIN users ON news.Username = users.Username WHERE users.connected='$yourname' ORDER BY created DESC") or die(mysql_error()); How this works is, I have 2 tables, one containing news stories and one with users...the users can be linked with one another, therefor you see their story. This part works GREAT, but the user doesn't see his own stories. Currenly it's getting every news story, except the users news story...how can I modify the QUERY that it also includes the users news stories?
  6. So i am trying to get a list of items out of my MySql database but my loop is not creating the array correctly, its dropping multiple rows when the key is the same name. <?php $search = 'item1'; $con = require_once('./dbconnect.php'); mysql_select_db("packages", $con); $package = mysql_query("SELECT * FROM $search", $con); while($item = mysql_fetch_row($package)){ $arr[$item[1]] = array('description' => $item[2], 'image' => $item[3]); } echo json_encode($arr); mysql_close($con); ?> So the loop works and does actually create the array with the various 'packages' in their respective array. The issue that i am having is that mysql_fetch_row($package)) can and will contain multiple keys that are the same name but with different things in the array. For example, the database will be something like this: PACK LEV DESCRIPTION IMAGES item1 A1 description for stuff1 image1 item1 A2 description for more stuff image2 item1 B1 more stuff here image3 item2 A1 description here for item2 image1 item2 B1 description contents here image2 --------------------------------------------------------------------------------- My Above code will produce an array like this: Array ( [item1] => Array ( [description] => more stuff here [image] => image3 ) [item2] => Array ( [description] => description contents here [image] => image2 ) ) What i want the array to be is: Array ( [item1] => Array ( [A1] => Array ( [description] => description for stuff1 [image] => image1 ) [A2] => Array ( [description] => description for more stuff [image] => image2 ) [b1] => Array ( [description] => more stuff here [image] => image3 ) [item2] => Array ( [A1] => Array ( [description] => description here for item2 [image] => image1 ) [b1] => Array ( [description] => description contents here [image] => image2 ) ) ) I hope this makes sense..Thanks for looking
  • 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.