473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

php and mysql issues

I am having issues with connecting to my mysql database. I am not getting any error messages but when trying to add records nothing happens. I tried some code I found online to see if I could at least access my database but what I get is boggling me. My code is as follows:

Expand|Select|Wrap|Line Numbers
  1. <?
  2. // Connecting, selecting database
  3. $link = mysql_connect('localhost', 'user', 'pass')
  4.     or die('Could not connect: ' . mysql_error());
  5. echo 'Connected successfully';
  6. mysql_select_db('test') or die('Could not select database');
  7.  
  8. // Performing SQL query
  9. $query = 'SELECT * FROM addressbook';
  10. $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  11.  
  12. // Printing results in HTML
  13. echo "<table>\n";
  14. while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
  15.     echo "\t<tr>\n";
  16.     foreach ($line as $col_value) {
  17.         echo "\t\t<td>$col_value</td>\n";
  18.     }
  19.     echo "\t</tr>\n";
  20. }
  21. echo "</table>";
  22.  
  23. // Free resultset
  24. mysql_free_result($result);
  25.  
  26. // Closing connection
  27. mysql_close($link);
  28. ?>
  29.  
  30. and what I get is a page that displays this:
  31.  
  32. \n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t\n"; foreach ($line as $col_value) { echo "\t\t$col_value\n"; } echo "\t\n"; } echo ""; // Free resultset mysql_free_result($result); // Closing connection mysql_close($link); ?>

[Please use CODE tags when posting source code. Thanks! --pbmods]

To my understanding, what it is doing is it is taking the ">" from the first "<table\>" and calling it the ending tag. For some reason it does not want to display the table. I am not sure if there is something wrong with the configuration or what. I am unable to get access to my mysql server through phpmyadmin and am able to add databases and all functionality seems to be there. But for some reason it seems I am unable to connect through code on a PHP script I made. can anyone help me with this?

Also one more thing, which I'm not sure is really any kind of issue of concern or not but thought I should mention it is that, when I write php code using "<?php" I get absolutely nothing on the page where when using "<?" seems to be parsing the code fine on a simple "hello world" script as well as with a sendmail script.
Thanks

Mike
Jun 4 '07 #1
1 1185
Issue solved no longer need help on this, I'll probably be back for more issues sometime thought.

Mike

[REMOVED. --pbmods]
Jun 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Spidah | last post by:
Looking at the list of changes made in PHP5 one of them is "Removed the bundled MySQL client library" Does anyone know exactly what this means? I assume we will still be able to code for...
8
by: madcap | last post by:
Hi, Our company was looking for contract programmer to develop an internet/intranet application. We were approached by a freelancer who have quite a lot experience and his resume was...
5
by: sandy | last post by:
Hi All, I am a newbie to MySQL and Python. At the first place, I would like to know what are the general performance issues (if any) of using MySQL with Python. By performance, I wanted to...
4
by: MLH | last post by:
I am having failures processing the following command and I wonder if you can tell me what I must do in order to have success. When I try to run source mysql_dump.sql.txt ==> it is a problem...
175
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I...
1
by: Jim Carlock | last post by:
I have a couple questions about MySQL involving which version of MySQL to use. I'm looking for minimal memory use on a Windows XP machine. Which version would be best for this? And can anyone...
5
by: Ike | last post by:
Through Java, I am attempting to connect to a MySQL 4.12 server on a remote computer. I can connect fine via php. I cann connect fine via Java, through a servlet, when the servlet is on the same...
7
by: Ike | last post by:
Let's say I have a MySQL 4.12 database, opened to the internet on 111.111.111.111 allowing all incoming and outgoing ports. I have a username and password setup, which CAN connect to this database,...
0
by: Sam Flywheel | last post by:
Hello, all: I am pleased to announce that the MySQL Journal is moving forward. During the past two weeks, I've been discussing the journal with MySQL AB, and the plan that's been devised...
1
by: marcfischman | last post by:
Please help. I have a website running on a linux/apache/mysql/php server. I receive about 8,000-10,000 visitors a day with about 200,000 to 300,000 page views. The server is a RedHat Linux...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.