| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10
Comments:
<0> Moridin: mysql_query($sql) or die (mysql_error()); <-- the error message itself might be EXTREMEMLY helpful. <1> I got that <0> care to share? <1> it's just returning 0 replies <1> No error <0> oh <2> check what $input is <1> $input = $_GET['input'] <2> or print the query and run it directly <1> And I printed $input to the bottom, and it's spitting out <3> what v. of php are most ppl running ? <0> Moridin: mysql_query($sql) or die ("The sql that was executed was: ($sql)<br />The error was: (" . mysql_error() . ")"); <0> anytime you're building your sql string from user data or otherwise variables. always be sure to double check (not ***ume) what the actual sql string looks like and debug that first <4> Cool! It worked now when I put it on top of the page.. thanks alot for your help =) <0> Jstr: 4 or 5 would be my guess <0> easypwn: cheers
<3> anyone wanna help me config php5 ? when I load as a module, i get an error. <0> with apache? <1> Ok <3> yeap <1> I got it <0> then no <1> Should have had <3> blah, thnks Two-Bits <0> {$input} ? <1> $sql = "SELECT * FROM item_db WHERE name_english LIKE '%$input%'"; <2> that should work fine <2> print the query in the script so you can see what it actually is <0> Moridin: or concatenate or used double qutoed string and escaped the double quotes inside <2> then, if it looks right, copy it and run it directly <0> spox: his sql string was single quoted, it wasn't interpolated <2> the single quotes inside are fine <0> no, before <2> oh, what he has there should work fine <1> Yeah, what I got now is working <0> what he has now, yes <2> i missed that above part <0> Jstr: sorry, but i've never installed, configured, or ever actually run apache in my life <0> i think i downloaded it once, but never opened the archive <3> no worries.. <1> Plah <1> Awesome <1> I got it searching now <3> Moridin: are you new to php ? <1> Yep <1> Just started yesterday. <3> cool. <1> So when I run into stuff like I'm running into now, where the first field of the result is being printed twice <1> I sit here and scratch my head in wonder. <1> and wonder what I broke and how. <3> yea <1> The same query in sql returns correctly, but when it prints, it prints the first field twice, and I dunno what's up with that. <0> when i worked at walmart, we got nifty "***ociate in Training" badges so customers would leave us alone <0> i wore mine like a month later than i was supposed to <3> lol <0> you can't pull that same stunt here Jstr <3> rofl. <3> Two-Bits: I am not trying to pull "the same stunt" just being honest, I am still learning php <0> well in that regard, so am I. but i'm not "new" <3> ok, maybe i used the wrong "word". <3> But i do feel new :"D <1> ok, this is my current working code <1> http://pastebin.ca/58483 <0> you've been hanging around since october man <1> As far as I can tell, it shouldn't be printing the first field twice, but it is <0> while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { <1> Is that totally wrong? :( <0> your array will literally have every field duplicated <1> Plah, I'm stupid. <0> dont use MYSQL_BOTH if you're going to foreach loop, or use a normal numeric loop, or best yet, dont use a loop <1> What should I do rather than a loop? <0> depends on what they query is for <1> The query is to search the database and pull up results <0> for the same reasons you should not be using select * <1> Well, I mean to not use select * when it's finished <0> a loop is appropriate for results, but not always appropriate for looping fields. you should know precisely where you want each field to appear and anything that needs to be done to those values
<1> I guess that's something a proper template would handle? <1> Is making sure the fields are put in place correctly? <0> template has nothing to do with it really, but yes it could <1> So when I make my template, don't use a loop <0> in that your template would have a spot for each variable. you can just as easily control it manually though <1> Well, with the search, I mean to eventually have it just list results <0> again, it all depends. you dont always want your template to use values directly from a database. so automating that step isn't always wise <1> and then someone could click on the thing, and it'd pull up the information <0> suppose you want to format numerical data as currency? <0> or calculate a birth date against the current date to display age <0> manually determine what data the template should have and give it the information it needs <1> Righto. <0> either way it should probably involve accessing each bit of information seperately like $row['myfield'] <0> another trick you might use is php.net/list <0> if you have an ordered array fetched, you can dump the values into variables in one shot. list($foo, $bar, $baz) = $row; <1> I like that. <1> Cuz already, I can see where I could have used that in my last test. <1> I was manually dumping parts of an array to variables <1> where I could have just list()'d the array. <1> Now <1> Is there a way I can do something <1> so that the first time the page is called up <1> It's not dumping everything? <1> So it like, waits for input before running the sql query? <0> the first time the page loads it should probably have no form data <0> you can test for this case <0> php.net/isset can be used on values you expect to get from $_GET or $_POST to determine if they exist. and in doing so, you can determine if the form was submitted <0> like if (isset($_GET['input'])) { do db stuffs } <1> Oh ok <1> If I want it to contruct a table <2> get some wood <2> and nails <1> Can I print "<tr><td> <1> or do I have to <tr><td><?php echo $this[that]?></td? <5> you can print whatever you want <1> Does print allow me to insert html code, or does it just print the text? <0> most people use echo instead of print though <0> for your purposes, they're the same <0> echo and print just send whatever data they are given to the client. php doesn't know or care if it's text or html or anything else <1> ok, cool <1> Wow. <1> That just escapes my brain. <1> I made a table, and the spacing was all weird <1> and I figured I'd take care of it later <1> and I add to variable declarations <1> and the spacing issue is gone <1> comment them out, it's back <0> pastebin? <0> it's magical fantastical <6> i get a hard-on thinking about it. <1> http://pastebin.ca/58504 <1> If I comment out the two $weight lines in the while (), my table spacings gets odd. <1> If I don't, it's perfect <0> stands to reason you'd be leaving a cell empty otherwise <0> your browser might show the cell as somewhat collapsed <0> where the border seems raised and the cells sunk in, empty cells sometimes appear to still be raised <0> which can be avoided by explicitly putting in a space <2> ! <5> home time! <0> http://www.youtube.com/watch?v=8CL2hetqpfg that's it.. i want one <7> hi <8> hi <8> http://pastebin.com/734085 <8> there is the code, and continue, (i put modifications and still continue the same problem spox) <8> I did as you told me and nothing <8> the problem is escaping the special chars, because in the sql sentence show me error <8> 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 '' at line 1 <9> $top_guia[$i][0] probably has no value. <9> var_dump($top_guia[$i][0]); <8> no, its the id, because before I took it by the db <8> the problem is in the value that I need to escape the special chars, and still I didnt fix it, i used all that told me <8> :S <6> me too.
Return to
#php or Go to some related
logs:
#india #chat-world #chat-world #java azrabijan #india sixsity #c++ t penang sareke
|
|