mySQL help please

Started on the old forum in October 2010 · view the original in the archive · old links redirect here

4 replies · 392 views · started 16 years ago · 1 min read

2 participants
Guest #1
<?php $connect = mysql_connect('localhost', 'root', ''); if (!$connect){ die('Could not connect: ' . mysql_error()); } echo 'Connected successfuly' . ' '; mysql_select_db("site"); $insert = "INSERT INTO site (name) VALUES ('waptrick.com');"; mysql_query("$insert"); $query = "SELECT name FROM games"; $result = mysql_query($query); $my_rows; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $my_rows = $my_rows . "Site Name : {$row['name']} "; } mysql_close($connect); echo "$my_rows;" ?>

//////////////////////////////////////////////// im having 2 problems with this code...the first is its not inserting the new row into the database the second is "Notice: Undefined variable: my_rows in C:\wamp\www\mysql\connect.php on line 22"

i cant work out the problem for either one of these errors could someone please help me

Added after 51 minutes:

got it to insert the row im just having this problem "Notice: Undefined variable: my_rows in C:\wamp\www\mysql\connect.php on line 22" still anything ive missed ?

Guest #3

$my_rows = $my_rows . "Site Name : {$row['name']} ";

i cancel out the error by using $my_rows = @$my_rows . "Site Name : {$row['name']} "; to not display the error so im guessing thats the cause but why and how would i fix it ?

Guest #5

thanks $my_rows=NULL; worked perfectly

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close