LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-13-2004, 05:07 AM   #1
nazdrowie
Member
 
Registered: Oct 2004
Distribution: Debian
Posts: 39

Rep: Reputation: 15
php and mysql blues


PHP does not want to cooperate! Co za kurwa jebana! Just kidding. I'm going through this tutorial on php/mysql:

http://dev.mysql.com/tech-resources/...s/ddws/26.html

and for some reason, the following chunk of code does not do what it's supposed to do:

Code:
    // Display the text of each joke in a paragraph
    // with a "Delete this Joke" link next to each.
    while ( $row = mysql_fetch_array($result) ) {
      $jokeid = $row["ID"];
      $joketext = $row["JokeText"];
      echo("<P>$joketext " .
           "<A HREF='$PHP_SELF?deletejoke=$jokeid'>" .
           "Delete this Joke</A></P>");
    }
The problem is that upon clicking the "Delete this joke" link, the url we're sent to looks like "http://foo.org/foo.php?deletejoke=" <-- Note the missing number/value after the equals sign. I did some digging around and it turns out that $jokeid does not get a value assigned from $row["ID"]. Why is that?

By the way, $joketext gets the right stuff assigned to it from $row["JokeText"] no problem, which is a string, and $row["ID"] is supposed to be an integer.
 
Old 12-13-2004, 07:44 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Are you sure in mysql table, the field is named 'ID', not 'id' ?
 
Old 12-13-2004, 11:19 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Did you select ID in your query?
 
Old 12-13-2004, 01:57 PM   #4
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Rep: Reputation: 30
if you know the order of your columns numerical you can user fetch_arry($result, MYSQL_NUM),
this will return the number indexs of each columns, so $row[0] = row['id'], sometimes this is earier to remeber then names indexs.
 
Old 12-13-2004, 04:00 PM   #5
nazdrowie
Member
 
Registered: Oct 2004
Distribution: Debian
Posts: 39

Original Poster
Rep: Reputation: 15
Thank you so much for the replies

Cedrik, I thought that SQL is case insensitive, so long as you're consistent within a query, say using only 'id' or only 'ID' throughout the whole query and not mixing.

Hko, you're right on the money. I hadn't copied and pasted the code from the link I gave, I had built it up from a previous version that was given in an earlier stage of the tutorial -- OOOPS. Good eye, Hko.

djgerbavore, thanks for the tip.
 
Old 12-13-2004, 05:52 PM   #6
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Rep: Reputation: 30
another thing is after a mysql command that you are unsure you can put
Code:
$row =  mysql_fetch_array($result) or die mysql_error();
which will give you more insight on the problems you are having
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql-server4.1 and mod php-mysql conflig kernelvn *BSD 0 06-18-2005 11:52 AM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 08:54 PM
php4 mysql, installation, php-pages with mysql info stay empty dnla Linux - Software 2 03-14-2004 02:54 PM
Installing MySQL.4.0.17 and php support for Mysql on RedHat 9.0 Neha Linux - Software 13 12-29-2003 12:06 AM
Apache Mysql Php: mysql with php doesn't work breakerfall Linux - Networking 6 12-27-2003 08:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration