• Questions That Don't Need Their Own Thread v3
    4,068 replies, posted
  • [QUOTE=Bomber9900;35292100]Nope, i've had it checked by two sources and both of them say the insert statement is fine. I'll check the permissions but my SQL account has global permissions so I don't think that would be the issue?[/QUOTE] obviously you're doing something wrong if you can't do such a common action
  • [QUOTE=Ac!dL3ak;35292121]obviously you're doing something wrong if you can't do such a common action[/QUOTE] I know i'm doing something wrong but I can't find the issue [code]$result = $con->query("INSERT INTO $tbl_name VALUES ('" . $name . ", " . $category . ", " . $class . ", " . $level . ", " . $bind . ", " . $tier . ", $trade.", $ilvl . ", " . $amod . ", " . $xdmg . ", " . $description . ", " . $description2 . ", " . $description3 . ", " . $sprice . ", " . $bprice . ", " . $percent . ", " . $source . ", " . $tnail . "')") or die(mysql_error());[/code]
  • try changing [code], $ilvl . ",[/code] to [code], ". $ilvl . ",[/code] [editline]25th March 2012[/editline] same with $trade before it
  • Something that sometimes helps is if you create a dummy file with dummy data with the same variable names that are used in the query, then run an echo with what would have been the query and see if it's all going through properly.
  • [QUOTE=Bomber9900;35292170]I know i'm doing something wrong but I can't find the issue [code]$result = $con->query("INSERT INTO $tbl_name VALUES ('" . $name . ", " . $category . ", " . $class . ", " . $level . ", " . $bind . ", " . $tier . ", $trade.", $ilvl . ", " . $amod . ", " . $xdmg . ", " . $description . ", " . $description2 . ", " . $description3 . ", " . $sprice . ", " . $bprice . ", " . $percent . ", " . $source . ", " . $tnail . "')") or die(mysql_error());[/code][/QUOTE] i'm p. sure it's the query (or even a PHP syntax error) try something like this [code]$result = $con->query("INSERT INTO `{$tbl_name}` VALUES ('{$name}', '{$category}', '{$class}', '{$level}', '{$bind}', '{$tier}', '{$trade}', '{$ilvl}', '{$amod}', '{$xdmg}', '{$description}', '{$description2}', '{$description3}', '{$sprice}', '{$bprice}', '{$percent}','{$source}', '{$tnai}')") or die(mysql_error());[/code] you're using a fucking template aren't you this actual query is a bad idea, you shoud invest in PDO [editline]hi[/editline] and yeah, you should actually see what you're putting into this query
  • umm no im not using a fucking template this is all coded from scratch. I'll try and follow up on these suggestions. This is pretty much my second day working with PHP so.
  • [QUOTE=Ac!dL3ak;35292106]position:absolute, maybe?[/QUOTE] That worked great to position it, how can I change what it's relative to? Or perhaps have a drop-down effect.
  • [QUOTE=Bomber9900;35292412]umm no im not using a fucking template this is all coded from scratch. I'll try and follow up on these suggestions. This is pretty much my second day working with PHP so.[/QUOTE] Not too late to start with ruby ;)
  • [QUOTE=Bomber9900;35285836][code]<?php mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); if ( isset ( $_POST['Submit'] ) ) //If submit is hit { $name = $_POST['name']; $category = $_POST['category']; $class = $_POST['class']; $level = $_POST['level']; $bind = $_POST['bind']; $tier = $_POST['tier']; $trade = $_POST['trade']; $ilvl = $_POST['ilvl']; $amod = $_POST['amod']; $xdmg = $_POST['xdmg']; $description = $_POST['description']; $description2 = $_POST['description2']; $description3 = $_POST['description3']; $sprice = $_POST['sprice']; $bprice = $_POST['bprice']; $percent = $_POST['percent']; $source = $_POST['source']; $tnail = $_POST['tnail']; $result=MYSQL_QUERY("INSERT INTO items (name, category, class, level, bind, tier, trade, ilvl, amod, xdmg, description, description2, description3, sprice, bprice, percent, source, tnail)". "VALUES ( '$name', '$category', '$class', '$level', '$bind', '$tier', '$trade', '$ilvl', '$amod', '$xdmg', '$description', '$description2', '$description3', '$sprice', '$bprice', '$percent', '$source', '$tnail' )")or die( "<p><span style=\"color: red;\">Unable to select table</span></p>"); mysql_close(); //confirm echo "<p><span style=\"color: red;\">Thank You; your comments have been entered in my database. DO NOT REFRESH THE PAGE or data will be sent again.</span></p>"; } else { // close php so we can put in our code ?>[/code] Why the hell won't this submit to my database?[/QUOTE] have you echo'd any of them to test if they all have string? for the () before VALUES you need (`blah`,`blah`)
  • Run a die() on the sql statement and then try and run it in an client such as Heidi SQL to see what happens
  • can anyone make sense of this please? am i meant to edit the file to suit my own joystick or does the script do that automatically? [url]http://code.google.com/p/javascript-joystick/source/browse/trunk/examples/javascript/joystick.js[/url]
  • not exactly sure if this goes here, but anyway i made a website and now i obviously want to put it on the internet is webhosting required or do i just need to buy a domain? i'm pretty new to this kind of stuff
  • webhosting is required and you need to either get a free domain or buy one. free co.cc or dot.tk (frees are frowned upon) any free web/domains are frowned upon
  • [QUOTE=Shortyish;35295498]not exactly sure if this goes here, but anyway i made a website and now i obviously want to put it on the internet is webhosting required or do i just need to buy a domain? i'm pretty new to this kind of stuff[/QUOTE] People around here like to buy their domains from [url]http://namecheap.com[/url] you should buy your shared hosting depending on your location, for e.g if you are in America there will be limitless options. I'm in Australia and found this company to be promising [url]http://www.netvirtue.com.au/economy-hosting[/url]
  • Right so quick php question. I've managed to sort most of my issues through trial and error but this isn't really an issue more of a how would I achieve this style thing. Right so here it goes. Say a user clicks on the link and it sends them to domain/db.php?category=1 I have three categories in the database, how would I get the database page only to show whats listed for the specific category link the user clicks on?
  • [QUOTE=Bomber9900;35299913]Right so quick php question. I've managed to sort most of my issues through trial and error but this isn't really an issue more of a how would I achieve this style thing. Right so here it goes. Say a user clicks on the link and it sends them to domain/db.php?category=1 I have three categories in the database, how would I get the database page only to show whats listed for the specific category link the user clicks on?[/QUOTE] I'm not sure if this is what you meant. [code]mysql_query("SELECT * FROM table WHERE category=''.@$_GET['category'].''");[/code] Not that you shouldn't directly use $_GET in the database, it's just to give you an idea.
  • Ahh so I was on the right track. I think I can nail it soon. [editline]26th March 2012[/editline] Nevermind, i'm completely fucking lost.
  • [QUOTE=Bomber9900;35300202]Ahh so I was on the right track. I think I can nail it soon. [editline]26th March 2012[/editline] Nevermind, i'm completely fucking lost.[/QUOTE] If you have steam i'm willing to lend a hand, private message me your steam name if you're interested.
  • Making a php test in class. So we have to make a php file that uses fopen to read a file. Then we have to read out the price of the book and display it. And after that we have to calculate the tax on a book, HOW IS THIS EVEN POSSIBLE USING FOPEN/FREAD/ANY OTHER F THING?! [code]Handboek HTML5 10.25 PHP5 31.25 Ajax 15.25 [/code] The text file. [code] <?php $myFile = "artbestand.txt"; $test = fopen("$myFile", "r"); $theData = fread($test, filesize($myFile)); fclose($test); echo $theData; ?> [/code] And my current code.
  • [QUOTE=MitchvW;35301565]Making a php test in class. So we have to make a php file that uses fopen to read a file. Then we have to read out the price of the book and display it. And after that we have to calculate the tax on a book, HOW IS THIS EVEN POSSIBLE USING FOPEN/FREAD/ANY OTHER F THING?! [code]Handboek HTML5 10.25 PHP5 31.25 Ajax 15.25 [/code] The text file. [code] <?php $myFile = "artbestand.txt"; $test = fopen("$myFile", "r"); $theData = fread($test, filesize($myFile)); fclose($test); echo $theData; ?> [/code] And my current code.[/QUOTE] Using text files to store data such as that is retarted, should be in a database. However, you're best approach would be using [code]$array = explode('\n',$theData);[/code] That should return each new line into an array which you can then use.
  • [QUOTE=kragmars102;35301609]Using text files to store data such as that is retarted, should be in a database. However, you're best approach would be using [code]$array = explode('\n',$theData);[/code] That should return each new line into an array which you can then use.[/QUOTE] Yeah tell that to this retard of a teacher. I currently got some array things going on [code] <?php $file_handle = fopen("artbestand.txt", "r"); $lines = array(); while (!feof($file_handle)) { print_r($lines); $line = fgets($file_handle); if(!empty($line)) $lines[] = $line; } fclose($file_handle); ?> [/code] And it outputs this [code] Array ( ) Array ( [0] => Handboek HTML5 ) Array ( [0] => Handboek HTML5 [1] => 10.25 ) Array ( [0] => Handboek HTML5 [1] => 10.25 [2] => PHP5 ) Array ( [0] => Handboek HTML5 [1] => 10.25 [2] => PHP5 [3] => 31.25 ) Array ( [0] => Handboek HTML5 [1] => 10.25 [2] => PHP5 [3] => 31.25 [4] => Ajax ) Array ( [0] => Handboek HTML5 [1] => 10.25 [2] => PHP5 [3] => 31.25 [4] => Ajax [5] => 15.25 ) [/code] [editline]26th March 2012[/editline] Well fuck it class is over and the last result I got is that PHP 5 is the most expensive book, no prices and no tax.
  • [QUOTE=kragmars102;35300173]I'm not sure if this is what you meant. [code]mysql_query("SELECT * FROM table WHERE category=''.@$_GET['category'].''");[/code] Not that you shouldn't directly use $_GET in the database, it's just to give you an idea.[/QUOTE] I disagree with this; you should [b]never[/b] use @, it suppresses ALL error, warning, and info messages- if you call a function using it, any function that function calls won't give an error or a warning. Plus, you should be handling the case yourself- if it doesn't exist, you should give an error. [editline]26th March 2012[/editline] [php] $fd = fopen("artbestand.txt","r"); $books = array(); while(!feof($fd)) { $books[fgets($fd)] = fgets($fd); } print_r($book); [/php] maybe?